From c6ce066995e0a93988b55097a6649fd230757065 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 23 Dec 2022 05:06:55 +0000 Subject: [PATCH] CodeGen from PR 21890 in Azure/azure-rest-api-specs Merge 737c81cf81755ac305a3457e735323a7eeeb2954 into f012b6bceb90be88947c3f8a21dab9c78b0b4a6d --- .../azure-mgmt-databoxedge/_meta.json | 11 +- .../azure/mgmt/datab/__init__.py | 18 +- .../azure/mgmt/datab/_configuration.py | 70 +- .../datab/_data_box_edge_management_client.py | 204 +- .../azure/mgmt/datab/_metadata.json | 39 +- .../azure/mgmt/datab/_patch.py | 20 + .../azure/mgmt/datab/_vendor.py | 27 + .../azure/mgmt/datab/_version.py | 9 + .../azure/mgmt/datab/aio/__init__.py | 15 +- .../azure/mgmt/datab/aio/_configuration.py | 64 +- .../aio/_data_box_edge_management_client.py | 184 +- .../azure/mgmt/datab/aio/_patch.py | 20 + .../mgmt/datab/aio/operations/__init__.py | 42 +- .../aio/operations/_addons_operations.py | 649 +- .../aio/operations/_alerts_operations.py | 238 +- .../operations/_available_skus_operations.py | 146 +- .../_bandwidth_schedules_operations.py | 630 +- .../aio/operations/_containers_operations.py | 807 ++- .../aio/operations/_devices_operations.py | 2084 +++--- .../datab/aio/operations/_jobs_operations.py | 140 +- .../_monitoring_config_operations.py | 644 +- .../datab/aio/operations/_nodes_operations.py | 158 +- .../mgmt/datab/aio/operations/_operations.py | 139 +- .../_operations_status_operations.py | 140 +- .../aio/operations/_orders_operations.py | 674 +- .../azure/mgmt/datab/aio/operations/_patch.py | 20 + .../datab/aio/operations/_roles_operations.py | 617 +- .../aio/operations/_shares_operations.py | 760 +- ..._storage_account_credentials_operations.py | 635 +- .../_storage_accounts_operations.py | 634 +- .../aio/operations/_triggers_operations.py | 628 +- .../datab/aio/operations/_users_operations.py | 624 +- .../azure/mgmt/datab/models/__init__.py | 832 +-- .../_data_box_edge_management_client_enums.py | 352 +- .../azure/mgmt/datab/models/_models.py | 5119 -------------- .../azure/mgmt/datab/models/_models_py3.py | 5305 +++++++------- .../azure/mgmt/datab/models/_patch.py | 20 + .../azure/mgmt/datab/operations/__init__.py | 42 +- .../datab/operations/_addons_operations.py | 809 ++- .../datab/operations/_alerts_operations.py | 304 +- .../operations/_available_skus_operations.py | 179 +- .../_bandwidth_schedules_operations.py | 783 +- .../operations/_containers_operations.py | 1023 ++- .../datab/operations/_devices_operations.py | 2650 ++++--- .../mgmt/datab/operations/_jobs_operations.py | 178 +- .../_monitoring_config_operations.py | 798 ++- .../datab/operations/_nodes_operations.py | 196 +- .../mgmt/datab/operations/_operations.py | 167 +- .../_operations_status_operations.py | 178 +- .../datab/operations/_orders_operations.py | 842 ++- .../azure/mgmt/datab/operations/_patch.py | 20 + .../datab/operations/_roles_operations.py | 763 +- .../datab/operations/_shares_operations.py | 943 ++- ..._storage_account_credentials_operations.py | 788 ++- .../_storage_accounts_operations.py | 786 ++- .../datab/operations/_triggers_operations.py | 771 +- .../datab/operations/_users_operations.py | 772 +- .../azure/mgmt/databoxedge/__init__.py | 4 + .../azure/mgmt/databoxedge/_configuration.py | 22 +- .../_data_box_edge_management_client.py | 132 +- .../azure/mgmt/databoxedge/_serialization.py | 1967 ++++++ .../mgmt/databoxedge/aio/_configuration.py | 10 +- .../aio/_data_box_edge_management_client.py | 120 +- .../azure/mgmt/databoxedge/models.py | 2 +- .../mgmt/databoxedge/v2019_03_01/__init__.py | 18 +- .../databoxedge/v2019_03_01/_configuration.py | 70 +- .../_data_box_edge_management_client.py | 168 +- .../databoxedge/v2019_03_01/_metadata.json | 39 +- .../mgmt/databoxedge/v2019_03_01/_patch.py | 20 + .../mgmt/databoxedge/v2019_03_01/_vendor.py | 27 + .../mgmt/databoxedge/v2019_03_01/_version.py | 9 + .../databoxedge/v2019_03_01/aio/__init__.py | 15 +- .../v2019_03_01/aio/_configuration.py | 64 +- .../aio/_data_box_edge_management_client.py | 143 +- .../databoxedge/v2019_03_01/aio/_patch.py | 20 + .../v2019_03_01/aio/operations/__init__.py | 30 +- .../aio/operations/_alerts_operations.py | 238 +- .../_bandwidth_schedules_operations.py | 630 +- .../aio/operations/_devices_operations.py | 1858 +++-- .../aio/operations/_jobs_operations.py | 140 +- .../v2019_03_01/aio/operations/_operations.py | 139 +- .../_operations_status_operations.py | 140 +- .../aio/operations/_orders_operations.py | 601 +- .../v2019_03_01/aio/operations/_patch.py | 20 + .../aio/operations/_roles_operations.py | 617 +- .../aio/operations/_shares_operations.py | 760 +- ..._storage_account_credentials_operations.py | 635 +- .../aio/operations/_triggers_operations.py | 628 +- .../aio/operations/_users_operations.py | 617 +- .../v2019_03_01/models/__init__.py | 473 +- .../_data_box_edge_management_client_enums.py | 233 +- .../databoxedge/v2019_03_01/models/_models.py | 2752 -------- .../v2019_03_01/models/_models_py3.py | 2935 ++++---- .../databoxedge/v2019_03_01/models/_patch.py | 20 + .../v2019_03_01/operations/__init__.py | 30 +- .../operations/_alerts_operations.py | 304 +- .../_bandwidth_schedules_operations.py | 783 +- .../operations/_devices_operations.py | 2355 +++++-- .../operations/_jobs_operations.py | 178 +- .../v2019_03_01/operations/_operations.py | 167 +- .../_operations_status_operations.py | 178 +- .../operations/_orders_operations.py | 738 +- .../v2019_03_01/operations/_patch.py | 20 + .../operations/_roles_operations.py | 763 +- .../operations/_shares_operations.py | 943 ++- ..._storage_account_credentials_operations.py | 788 ++- .../operations/_triggers_operations.py | 771 +- .../operations/_users_operations.py | 763 +- .../mgmt/databoxedge/v2019_07_01/__init__.py | 18 +- .../databoxedge/v2019_07_01/_configuration.py | 70 +- .../_data_box_edge_management_client.py | 173 +- .../databoxedge/v2019_07_01/_metadata.json | 39 +- .../mgmt/databoxedge/v2019_07_01/_patch.py | 20 + .../mgmt/databoxedge/v2019_07_01/_vendor.py | 27 + .../mgmt/databoxedge/v2019_07_01/_version.py | 9 + .../databoxedge/v2019_07_01/aio/__init__.py | 15 +- .../v2019_07_01/aio/_configuration.py | 64 +- .../aio/_data_box_edge_management_client.py | 148 +- .../databoxedge/v2019_07_01/aio/_patch.py | 20 + .../v2019_07_01/aio/operations/__init__.py | 32 +- .../aio/operations/_alerts_operations.py | 238 +- .../_bandwidth_schedules_operations.py | 630 +- .../aio/operations/_devices_operations.py | 1858 +++-- .../aio/operations/_jobs_operations.py | 140 +- .../aio/operations/_nodes_operations.py | 158 +- .../v2019_07_01/aio/operations/_operations.py | 139 +- .../_operations_status_operations.py | 140 +- .../aio/operations/_orders_operations.py | 601 +- .../v2019_07_01/aio/operations/_patch.py | 20 + .../aio/operations/_roles_operations.py | 617 +- .../aio/operations/_shares_operations.py | 760 +- ..._storage_account_credentials_operations.py | 635 +- .../aio/operations/_triggers_operations.py | 628 +- .../aio/operations/_users_operations.py | 619 +- .../v2019_07_01/models/__init__.py | 487 +- .../_data_box_edge_management_client_enums.py | 239 +- .../databoxedge/v2019_07_01/models/_models.py | 2861 -------- .../v2019_07_01/models/_models_py3.py | 3086 ++++---- .../databoxedge/v2019_07_01/models/_patch.py | 20 + .../v2019_07_01/operations/__init__.py | 32 +- .../operations/_alerts_operations.py | 304 +- .../_bandwidth_schedules_operations.py | 783 +- .../operations/_devices_operations.py | 2355 +++++-- .../operations/_jobs_operations.py | 178 +- .../operations/_nodes_operations.py | 196 +- .../v2019_07_01/operations/_operations.py | 167 +- .../_operations_status_operations.py | 178 +- .../operations/_orders_operations.py | 738 +- .../v2019_07_01/operations/_patch.py | 20 + .../operations/_roles_operations.py | 763 +- .../operations/_shares_operations.py | 943 ++- ..._storage_account_credentials_operations.py | 788 ++- .../operations/_triggers_operations.py | 771 +- .../operations/_users_operations.py | 765 +- .../mgmt/databoxedge/v2019_08_01/__init__.py | 18 +- .../databoxedge/v2019_08_01/_configuration.py | 70 +- .../_data_box_edge_management_client.py | 191 +- .../databoxedge/v2019_08_01/_metadata.json | 39 +- .../mgmt/databoxedge/v2019_08_01/_patch.py | 20 + .../mgmt/databoxedge/v2019_08_01/_vendor.py | 27 + .../mgmt/databoxedge/v2019_08_01/_version.py | 9 + .../databoxedge/v2019_08_01/aio/__init__.py | 15 +- .../v2019_08_01/aio/_configuration.py | 64 +- .../aio/_data_box_edge_management_client.py | 168 +- .../databoxedge/v2019_08_01/aio/_patch.py | 20 + .../v2019_08_01/aio/operations/__init__.py | 38 +- .../aio/operations/_alerts_operations.py | 238 +- .../_bandwidth_schedules_operations.py | 630 +- .../aio/operations/_containers_operations.py | 807 ++- .../aio/operations/_devices_operations.py | 1858 +++-- .../aio/operations/_jobs_operations.py | 140 +- .../aio/operations/_nodes_operations.py | 158 +- .../v2019_08_01/aio/operations/_operations.py | 139 +- .../_operations_status_operations.py | 140 +- .../aio/operations/_orders_operations.py | 601 +- .../v2019_08_01/aio/operations/_patch.py | 20 + .../aio/operations/_roles_operations.py | 617 +- .../aio/operations/_shares_operations.py | 760 +- .../aio/operations/_skus_operations.py | 155 +- ..._storage_account_credentials_operations.py | 635 +- .../_storage_accounts_operations.py | 634 +- .../aio/operations/_triggers_operations.py | 628 +- .../aio/operations/_users_operations.py | 624 +- .../v2019_08_01/models/__init__.py | 553 +- .../_data_box_edge_management_client_enums.py | 263 +- .../databoxedge/v2019_08_01/models/_models.py | 3305 --------- .../v2019_08_01/models/_models_py3.py | 3414 +++++---- .../databoxedge/v2019_08_01/models/_patch.py | 20 + .../v2019_08_01/operations/__init__.py | 38 +- .../operations/_alerts_operations.py | 304 +- .../_bandwidth_schedules_operations.py | 783 +- .../operations/_containers_operations.py | 1023 ++- .../operations/_devices_operations.py | 2355 +++++-- .../operations/_jobs_operations.py | 178 +- .../operations/_nodes_operations.py | 196 +- .../v2019_08_01/operations/_operations.py | 167 +- .../_operations_status_operations.py | 178 +- .../operations/_orders_operations.py | 738 +- .../v2019_08_01/operations/_patch.py | 20 + .../operations/_roles_operations.py | 763 +- .../operations/_shares_operations.py | 943 ++- .../operations/_skus_operations.py | 189 +- ..._storage_account_credentials_operations.py | 788 ++- .../_storage_accounts_operations.py | 786 ++- .../operations/_triggers_operations.py | 771 +- .../operations/_users_operations.py | 772 +- .../v2020_05_01_preview/__init__.py | 18 +- .../v2020_05_01_preview/_configuration.py | 70 +- .../_data_box_edge_management_client.py | 199 +- .../v2020_05_01_preview/_metadata.json | 39 +- .../databoxedge/v2020_05_01_preview/_patch.py | 20 + .../v2020_05_01_preview/_vendor.py | 27 + .../v2020_05_01_preview/_version.py | 9 + .../v2020_05_01_preview/aio/__init__.py | 15 +- .../v2020_05_01_preview/aio/_configuration.py | 64 +- .../aio/_data_box_edge_management_client.py | 179 +- .../v2020_05_01_preview/aio/_patch.py | 20 + .../aio/operations/__init__.py | 40 +- .../aio/operations/_alerts_operations.py | 240 +- .../operations/_available_skus_operations.py | 148 +- .../_bandwidth_schedules_operations.py | 634 +- .../aio/operations/_containers_operations.py | 811 ++- .../aio/operations/_devices_operations.py | 1877 +++-- .../aio/operations/_jobs_operations.py | 142 +- .../aio/operations/_nodes_operations.py | 160 +- .../aio/operations/_operations.py | 141 +- .../_operations_status_operations.py | 142 +- .../aio/operations/_orders_operations.py | 610 +- .../aio/operations/_patch.py | 20 + .../aio/operations/_roles_operations.py | 626 +- .../aio/operations/_shares_operations.py | 769 +- .../aio/operations/_skus_operations.py | 157 +- ..._storage_account_credentials_operations.py | 639 +- .../_storage_accounts_operations.py | 638 +- .../aio/operations/_triggers_operations.py | 637 +- .../aio/operations/_users_operations.py | 633 +- .../v2020_05_01_preview/models/__init__.py | 603 +- .../_data_box_edge_management_client_enums.py | 293 +- .../v2020_05_01_preview/models/_models.py | 3657 ---------- .../v2020_05_01_preview/models/_models_py3.py | 3671 +++++----- .../v2020_05_01_preview/models/_patch.py | 20 + .../operations/__init__.py | 40 +- .../operations/_alerts_operations.py | 312 +- .../operations/_available_skus_operations.py | 184 +- .../_bandwidth_schedules_operations.py | 799 ++- .../operations/_containers_operations.py | 1043 ++- .../operations/_devices_operations.py | 2402 +++++-- .../operations/_jobs_operations.py | 182 +- .../operations/_nodes_operations.py | 200 +- .../operations/_operations.py | 172 +- .../_operations_status_operations.py | 182 +- .../operations/_orders_operations.py | 750 +- .../v2020_05_01_preview/operations/_patch.py | 20 + .../operations/_roles_operations.py | 779 +- .../operations/_shares_operations.py | 959 ++- .../operations/_skus_operations.py | 193 +- ..._storage_account_credentials_operations.py | 804 ++- .../_storage_accounts_operations.py | 803 ++- .../operations/_triggers_operations.py | 793 ++- .../operations/_users_operations.py | 788 ++- .../mgmt/databoxedge/v2020_09_01/__init__.py | 18 +- .../databoxedge/v2020_09_01/_configuration.py | 70 +- .../_data_box_edge_management_client.py | 204 +- .../databoxedge/v2020_09_01/_metadata.json | 39 +- .../mgmt/databoxedge/v2020_09_01/_patch.py | 20 + .../mgmt/databoxedge/v2020_09_01/_vendor.py | 27 + .../mgmt/databoxedge/v2020_09_01/_version.py | 9 + .../databoxedge/v2020_09_01/aio/__init__.py | 15 +- .../v2020_09_01/aio/_configuration.py | 64 +- .../aio/_data_box_edge_management_client.py | 184 +- .../databoxedge/v2020_09_01/aio/_patch.py | 20 + .../v2020_09_01/aio/operations/__init__.py | 42 +- .../aio/operations/_addons_operations.py | 649 +- .../aio/operations/_alerts_operations.py | 238 +- .../operations/_available_skus_operations.py | 146 +- .../_bandwidth_schedules_operations.py | 630 +- .../aio/operations/_containers_operations.py | 807 ++- .../aio/operations/_devices_operations.py | 2084 +++--- .../aio/operations/_jobs_operations.py | 140 +- .../_monitoring_config_operations.py | 644 +- .../aio/operations/_nodes_operations.py | 158 +- .../v2020_09_01/aio/operations/_operations.py | 139 +- .../_operations_status_operations.py | 140 +- .../aio/operations/_orders_operations.py | 674 +- .../v2020_09_01/aio/operations/_patch.py | 20 + .../aio/operations/_roles_operations.py | 617 +- .../aio/operations/_shares_operations.py | 760 +- ..._storage_account_credentials_operations.py | 635 +- .../_storage_accounts_operations.py | 634 +- .../aio/operations/_triggers_operations.py | 628 +- .../aio/operations/_users_operations.py | 626 +- .../v2020_09_01/models/__init__.py | 813 +-- .../_data_box_edge_management_client_enums.py | 349 +- .../databoxedge/v2020_09_01/models/_models.py | 4986 ------------- .../v2020_09_01/models/_models_py3.py | 5114 ++++++++------ .../databoxedge/v2020_09_01/models/_patch.py | 20 + .../v2020_09_01/operations/__init__.py | 42 +- .../operations/_addons_operations.py | 809 ++- .../operations/_alerts_operations.py | 304 +- .../operations/_available_skus_operations.py | 179 +- .../_bandwidth_schedules_operations.py | 783 +- .../operations/_containers_operations.py | 1023 ++- .../operations/_devices_operations.py | 2650 ++++--- .../operations/_jobs_operations.py | 178 +- .../_monitoring_config_operations.py | 798 ++- .../operations/_nodes_operations.py | 196 +- .../v2020_09_01/operations/_operations.py | 167 +- .../_operations_status_operations.py | 178 +- .../operations/_orders_operations.py | 842 ++- .../v2020_09_01/operations/_patch.py | 20 + .../operations/_roles_operations.py | 763 +- .../operations/_shares_operations.py | 943 ++- ..._storage_account_credentials_operations.py | 788 ++- .../_storage_accounts_operations.py | 786 ++- .../operations/_triggers_operations.py | 771 +- .../operations/_users_operations.py | 774 +- .../v2020_09_01_preview/__init__.py | 18 +- .../v2020_09_01_preview/_configuration.py | 70 +- .../_data_box_edge_management_client.py | 207 +- .../v2020_09_01_preview/_metadata.json | 39 +- .../databoxedge/v2020_09_01_preview/_patch.py | 20 + .../v2020_09_01_preview/_vendor.py | 27 + .../v2020_09_01_preview/_version.py | 9 + .../v2020_09_01_preview/aio/__init__.py | 15 +- .../v2020_09_01_preview/aio/_configuration.py | 64 +- .../aio/_data_box_edge_management_client.py | 187 +- .../v2020_09_01_preview/aio/_patch.py | 20 + .../aio/operations/__init__.py | 42 +- .../aio/operations/_addons_operations.py | 658 +- .../aio/operations/_alerts_operations.py | 240 +- .../operations/_available_skus_operations.py | 148 +- .../_bandwidth_schedules_operations.py | 634 +- .../aio/operations/_containers_operations.py | 811 ++- .../aio/operations/_devices_operations.py | 2108 ++++-- .../aio/operations/_jobs_operations.py | 142 +- .../_monitoring_config_operations.py | 648 +- .../aio/operations/_nodes_operations.py | 160 +- .../aio/operations/_operations.py | 141 +- .../_operations_status_operations.py | 142 +- .../aio/operations/_orders_operations.py | 683 +- .../aio/operations/_patch.py | 20 + .../aio/operations/_roles_operations.py | 626 +- .../aio/operations/_shares_operations.py | 769 +- ..._storage_account_credentials_operations.py | 639 +- .../_storage_accounts_operations.py | 638 +- .../aio/operations/_triggers_operations.py | 637 +- .../aio/operations/_users_operations.py | 635 +- .../v2020_09_01_preview/models/__init__.py | 813 +-- .../_data_box_edge_management_client_enums.py | 349 +- .../v2020_09_01_preview/models/_models.py | 5037 ------------- .../v2020_09_01_preview/models/_models_py3.py | 5131 ++++++++------ .../v2020_09_01_preview/models/_patch.py | 20 + .../operations/__init__.py | 42 +- .../operations/_addons_operations.py | 829 ++- .../operations/_alerts_operations.py | 312 +- .../operations/_available_skus_operations.py | 184 +- .../_bandwidth_schedules_operations.py | 799 ++- .../operations/_containers_operations.py | 1043 ++- .../operations/_devices_operations.py | 2706 ++++--- .../operations/_jobs_operations.py | 182 +- .../_monitoring_config_operations.py | 814 ++- .../operations/_nodes_operations.py | 200 +- .../operations/_operations.py | 172 +- .../_operations_status_operations.py | 182 +- .../operations/_orders_operations.py | 856 ++- .../v2020_09_01_preview/operations/_patch.py | 20 + .../operations/_roles_operations.py | 779 +- .../operations/_shares_operations.py | 959 ++- ..._storage_account_credentials_operations.py | 804 ++- .../_storage_accounts_operations.py | 803 ++- .../operations/_triggers_operations.py | 793 ++- .../operations/_users_operations.py | 790 ++- .../mgmt/databoxedge/v2021_02_01/__init__.py | 26 + .../databoxedge/v2021_02_01/_configuration.py | 72 + .../_data_box_edge_management_client.py | 190 + .../databoxedge/v2021_02_01/_metadata.json | 121 + .../mgmt/databoxedge/v2021_02_01/_patch.py | 20 + .../mgmt/databoxedge/v2021_02_01/_vendor.py | 27 + .../mgmt/databoxedge/v2021_02_01/_version.py | 9 + .../databoxedge/v2021_02_01/aio/__init__.py | 23 + .../v2021_02_01/aio/_configuration.py | 72 + .../aio/_data_box_edge_management_client.py | 191 + .../databoxedge/v2021_02_01/aio/_patch.py | 20 + .../v2021_02_01/aio/operations/__init__.py | 57 + .../aio/operations/_addons_operations.py | 585 ++ .../aio/operations/_alerts_operations.py | 214 + .../operations/_available_skus_operations.py | 140 + .../_bandwidth_schedules_operations.py | 570 ++ .../aio/operations/_containers_operations.py | 723 ++ .../aio/operations/_devices_operations.py | 1777 +++++ .../_diagnostic_settings_operations.py | 609 ++ .../aio/operations/_jobs_operations.py | 121 + .../_monitoring_config_operations.py | 588 ++ .../aio/operations/_nodes_operations.py | 148 + .../v2021_02_01/aio/operations/_operations.py | 139 + .../_operations_status_operations.py | 121 + .../aio/operations/_orders_operations.py | 610 ++ .../v2021_02_01/aio/operations/_patch.py | 20 + .../aio/operations/_roles_operations.py | 551 ++ .../aio/operations/_shares_operations.py | 679 ++ ..._storage_account_credentials_operations.py | 575 ++ .../_storage_accounts_operations.py | 580 ++ .../_support_packages_operations.py | 274 + .../aio/operations/_triggers_operations.py | 558 ++ .../aio/operations/_users_operations.py | 558 ++ .../v2021_02_01/models/__init__.py | 393 ++ .../_data_box_edge_management_client_enums.py | 614 ++ .../v2021_02_01/models/_models_py3.py | 6280 +++++++++++++++++ .../databoxedge/v2021_02_01/models/_patch.py | 20 + .../v2021_02_01/operations/__init__.py | 57 + .../operations/_addons_operations.py | 715 ++ .../operations/_alerts_operations.py | 278 + .../operations/_available_skus_operations.py | 166 + .../_bandwidth_schedules_operations.py | 693 ++ .../operations/_containers_operations.py | 899 +++ .../operations/_devices_operations.py | 2263 ++++++ .../_diagnostic_settings_operations.py | 737 ++ .../operations/_jobs_operations.py | 156 + .../_monitoring_config_operations.py | 716 ++ .../operations/_nodes_operations.py | 181 + .../v2021_02_01/operations/_operations.py | 160 + .../_operations_status_operations.py | 156 + .../operations/_orders_operations.py | 759 ++ .../v2021_02_01/operations/_patch.py | 20 + .../operations/_roles_operations.py | 675 ++ .../operations/_shares_operations.py | 832 +++ ..._storage_account_credentials_operations.py | 700 ++ .../_storage_accounts_operations.py | 706 ++ .../_support_packages_operations.py | 311 + .../operations/_triggers_operations.py | 681 ++ .../operations/_users_operations.py | 684 ++ .../mgmt/databoxedge/v2021_02_01/py.typed | 1 + .../v2021_02_01_preview/__init__.py | 18 +- .../v2021_02_01_preview/_configuration.py | 70 +- .../_data_box_edge_management_client.py | 207 +- .../v2021_02_01_preview/_metadata.json | 39 +- .../databoxedge/v2021_02_01_preview/_patch.py | 20 + .../v2021_02_01_preview/_vendor.py | 27 + .../v2021_02_01_preview/_version.py | 9 + .../v2021_02_01_preview/aio/__init__.py | 15 +- .../v2021_02_01_preview/aio/_configuration.py | 64 +- .../aio/_data_box_edge_management_client.py | 187 +- .../v2021_02_01_preview/aio/_patch.py | 20 + .../aio/operations/__init__.py | 42 +- .../aio/operations/_addons_operations.py | 658 +- .../aio/operations/_alerts_operations.py | 240 +- .../operations/_available_skus_operations.py | 148 +- .../_bandwidth_schedules_operations.py | 634 +- .../aio/operations/_containers_operations.py | 811 ++- .../aio/operations/_devices_operations.py | 2108 ++++-- .../aio/operations/_jobs_operations.py | 142 +- .../_monitoring_config_operations.py | 648 +- .../aio/operations/_nodes_operations.py | 160 +- .../aio/operations/_operations.py | 141 +- .../_operations_status_operations.py | 142 +- .../aio/operations/_orders_operations.py | 683 +- .../aio/operations/_patch.py | 20 + .../aio/operations/_roles_operations.py | 626 +- .../aio/operations/_shares_operations.py | 769 +- ..._storage_account_credentials_operations.py | 639 +- .../_storage_accounts_operations.py | 638 +- .../aio/operations/_triggers_operations.py | 637 +- .../aio/operations/_users_operations.py | 635 +- .../v2021_02_01_preview/models/__init__.py | 837 +-- .../_data_box_edge_management_client_enums.py | 364 +- .../v2021_02_01_preview/models/_models.py | 5195 -------------- .../v2021_02_01_preview/models/_models_py3.py | 5381 +++++++------- .../v2021_02_01_preview/models/_patch.py | 20 + .../operations/__init__.py | 42 +- .../operations/_addons_operations.py | 829 ++- .../operations/_alerts_operations.py | 312 +- .../operations/_available_skus_operations.py | 184 +- .../_bandwidth_schedules_operations.py | 799 ++- .../operations/_containers_operations.py | 1043 ++- .../operations/_devices_operations.py | 2706 ++++--- .../operations/_jobs_operations.py | 182 +- .../_monitoring_config_operations.py | 814 ++- .../operations/_nodes_operations.py | 200 +- .../operations/_operations.py | 172 +- .../_operations_status_operations.py | 182 +- .../operations/_orders_operations.py | 856 ++- .../v2021_02_01_preview/operations/_patch.py | 20 + .../operations/_roles_operations.py | 779 +- .../operations/_shares_operations.py | 959 ++- ..._storage_account_credentials_operations.py | 804 ++- .../_storage_accounts_operations.py | 803 ++- .../operations/_triggers_operations.py | 793 ++- .../operations/_users_operations.py | 790 ++- 488 files changed, 164957 insertions(+), 114982 deletions(-) create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_vendor.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_version.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_patch.py delete mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_models.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_serialization.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_vendor.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_version.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_patch.py delete mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_models.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_vendor.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_version.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_patch.py delete mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_models.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_vendor.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_version.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_patch.py delete mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_models.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_vendor.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_version.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_patch.py delete mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_models.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_vendor.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_version.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_patch.py delete mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_models.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_vendor.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_version.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_patch.py delete mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_models.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/__init__.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_configuration.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_data_box_edge_management_client.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_metadata.json create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_vendor.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_version.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/__init__.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_configuration.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_data_box_edge_management_client.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/__init__.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_addons_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_alerts_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_available_skus_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_bandwidth_schedules_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_containers_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_devices_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_diagnostic_settings_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_jobs_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_monitoring_config_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_nodes_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_operations_status_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_orders_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_roles_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_shares_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_storage_account_credentials_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_storage_accounts_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_support_packages_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_triggers_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_users_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/__init__.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_data_box_edge_management_client_enums.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_models_py3.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/__init__.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_addons_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_alerts_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_available_skus_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_bandwidth_schedules_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_containers_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_devices_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_diagnostic_settings_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_jobs_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_monitoring_config_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_nodes_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_operations_status_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_orders_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_roles_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_shares_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_storage_account_credentials_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_storage_accounts_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_support_packages_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_triggers_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_users_operations.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/py.typed create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_vendor.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_version.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_patch.py delete mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_models.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_patch.py create mode 100644 sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_patch.py diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/_meta.json b/sdk/databoxedge/azure-mgmt-databoxedge/_meta.json index 2527cb55f4a7..cff474c6ae09 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/_meta.json +++ b/sdk/databoxedge/azure-mgmt-databoxedge/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.3.0", - "use": "@autorest/python@5.6.6", - "commit": "cc247b28bd6dc94786fb18e691d6331a168985f6", + "commit": "6b5f7fbe9fe34d788b76b154400c2912bb94df89", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/databoxedge/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.3.0", + "autorest": "3.9.2", + "use": [ + "@autorest/python@6.2.7", + "@autorest/modelerfour@4.24.3" + ], + "autorest_command": "autorest specification/databoxedge/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/databoxedge/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/__init__.py index e63196b6b98f..d2bcf6a47896 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/__init__.py @@ -7,10 +7,20 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_configuration.py index 70492096ac98..cc696fd00723 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_configuration.py @@ -6,65 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", "2020-12-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-12-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_data_box_edge_management_client.py index 0e619b3c6ee6..e689620b07db 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_data_box_edge_management_client.py @@ -6,41 +6,42 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import AddonsOperations -from .operations import MonitoringConfigOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from . import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations @@ -52,13 +53,15 @@ class DataBoxEdgeManagementClient(object): :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2020_12_01.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2020_12_01.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2020_12_01.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2020_12_01.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2020_12_01.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2020_12_01.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2020_12_01.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2020_12_01.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -66,109 +69,108 @@ class DataBoxEdgeManagementClient(object): :ivar addons: AddonsOperations operations :vartype addons: azure.mgmt.databoxedge.v2020_12_01.operations.AddonsOperations :ivar monitoring_config: MonitoringConfigOperations operations - :vartype monitoring_config: azure.mgmt.databoxedge.v2020_12_01.operations.MonitoringConfigOperations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2020_12_01.operations.MonitoringConfigOperations :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2020_12_01.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2020_12_01.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2020_12_01.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2020_12_01.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2020_12_01.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations :vartype containers: azure.mgmt.databoxedge.v2020_12_01.operations.ContainersOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2020_12_01.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2020_12_01.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) self.monitoring_config = MonitoringConfigOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None + + 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) -> None: self._client.close() - def __enter__(self): - # type: () -> DataBoxEdgeManagementClient + def __enter__(self) -> "DataBoxEdgeManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_metadata.json b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_metadata.json index f677ec50bfde..8ea87af46109 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_metadata.json +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_metadata.json @@ -5,25 +5,25 @@ "name": "DataBoxEdgeManagementClient", "filename": "_data_box_edge_management_client", "description": "The DataBoxEdge Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription ID.", + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription ID.", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=None, # type: Optional[str]", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -117,4 +116,4 @@ "triggers": "TriggersOperations", "users": "UsersOperations" } -} \ No newline at end of file +} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_vendor.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_version.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/_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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/__init__.py index c33d46ee91d8..fcb8775eaa10 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_configuration.py index 52416ed19fd9..d33ce3bc3cc5 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_configuration.py @@ -6,61 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", "2020-12-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-12-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_data_box_edge_management_client.py index 0cb209c359c9..6057bcbb3180 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_data_box_edge_management_client.py @@ -6,57 +6,63 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import AddonsOperations -from .operations import MonitoringConfigOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .. import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.databoxedge.v2020_12_01.aio.operations.Operations :ivar available_skus: AvailableSkusOperations operations - :vartype available_skus: azure.mgmt.databoxedge.v2020_12_01.aio.operations.AvailableSkusOperations + :vartype available_skus: + azure.mgmt.databoxedge.v2020_12_01.aio.operations.AvailableSkusOperations :ivar devices: DevicesOperations operations :vartype devices: azure.mgmt.databoxedge.v2020_12_01.aio.operations.DevicesOperations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2020_12_01.aio.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2020_12_01.aio.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2020_12_01.aio.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2020_12_01.aio.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2020_12_01.aio.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2020_12_01.aio.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2020_12_01.aio.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2020_12_01.aio.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -64,97 +70,101 @@ class DataBoxEdgeManagementClient(object): :ivar addons: AddonsOperations operations :vartype addons: azure.mgmt.databoxedge.v2020_12_01.aio.operations.AddonsOperations :ivar monitoring_config: MonitoringConfigOperations operations - :vartype monitoring_config: azure.mgmt.databoxedge.v2020_12_01.aio.operations.MonitoringConfigOperations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2020_12_01.aio.operations.MonitoringConfigOperations :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2020_12_01.aio.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2020_12_01.aio.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2020_12_01.aio.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2020_12_01.aio.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2020_12_01.aio.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations :vartype containers: azure.mgmt.databoxedge.v2020_12_01.aio.operations.ContainersOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2020_12_01.aio.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2020_12_01.aio.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) self.monitoring_config = MonitoringConfigOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/__init__.py index d70057be6458..febac852eb27 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/__init__.py @@ -25,23 +25,29 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'AddonsOperations', - 'MonitoringConfigOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_addons_operations.py index 7287aec3b494..4265496ebcd5 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_addons_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,109 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._addons_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_role_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AddonsOperations: - """AddonsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`addons` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_role( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AddonList"]: + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Addon"]: """Lists all the addons configured in the role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AddonList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_role.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -116,76 +152,79 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_role.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + + @distributed_trace_async async def get( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Addon": + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: """Gets a specific addon by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } async def _create_or_update_initial( self, @@ -193,43 +232,53 @@ async def _create_or_update_initial( role_name: str, addon_name: str, resource_group_name: str, - addon: "_models.Addon", - **kwargs - ) -> Optional["_models.Addon"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Addon"]] + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(addon, 'Addon') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -238,52 +287,143 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload async def begin_create_or_update( self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, - addon: "_models.Addon", - **kwargs - ) -> AsyncLROPoller["_models.Addon"]: + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: """Create or update a addon. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param addon: The addon properties. + :param addon: The addon properties. Required. :type addon: ~azure.mgmt.databoxedge.v2020_12_01.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Addon or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2020_12_01.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -291,79 +431,75 @@ async def begin_create_or_update( addon_name=addon_name, resource_group_name=resource_group_name, addon=addon, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -373,78 +509,79 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the addon on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, addon_name=addon_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_alerts_operations.py index bd674460d0ac..c42190ed2676 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._alerts_operations import build_get_request, build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AlertsOperations: - """AlertsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AlertList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,71 +142,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Alert": + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_available_skus_operations.py index 06b8e32035ae..0826a62bcda6 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._available_skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AvailableSkusOperations: - """AvailableSkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeSkuList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +135,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_bandwidth_schedules_operations.py index 3e4bc7a09474..44511135e897 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._bandwidth_schedules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BandwidthSchedulesOperations: - """BandwidthSchedulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.BandwidthSchedulesList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.BandwidthSchedule": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> Optional["_models.BandwidthSchedule"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +279,215 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> AsyncLROPoller["_models.BandwidthSchedule"]: + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +497,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_containers_operations.py index 31fc7b531c68..0315ec696f77 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._containers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_storage_account_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainersOperations: - """ContainersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_storage_account( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ContainerList"]: + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,78 +155,81 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Container": + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } async def _create_or_update_initial( self, @@ -197,43 +237,53 @@ async def _create_or_update_initial( storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> Optional["_models.Container"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -242,54 +292,155 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> AsyncLROPoller["_models.Container"]: + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2020_12_01.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Container or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Container] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2020_12_01.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -297,79 +448,75 @@ async def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -379,119 +526,116 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -501,80 +645,79 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_devices_operations.py index f3bc67df017d..6993ae38d182 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._devices_operations import ( + build_create_or_update_request, + build_create_or_update_security_settings_request, + build_delete_request, + build_download_updates_request, + build_generate_certificate_request, + build_get_extended_information_request, + build_get_network_settings_request, + build_get_request, + build_get_update_summary_request, + build_install_updates_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_scan_for_updates_request, + build_update_extended_information_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations: - """DevicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_subscription( - self, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,74 +160,90 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,226 +252,325 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDevice": + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } async def _create_or_update_initial( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> "_models.DataBoxEdgeDevice": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> AsyncLROPoller["_models.DataBoxEdgeDevice"]: + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -415,171 +580,243 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload async def update( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDevicePatch", - **kwargs - ) -> "_models.DataBoxEdgeDevice": + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - async def _download_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -589,223 +826,234 @@ async def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def begin_download_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._download_updates_initial( + raw_result = await self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def generate_certificate( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.GenerateCertResponse": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: """Generates certificate for activation key. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenerateCertResponse, or the result of cls(response) + :return: GenerateCertResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.GenerateCertResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCertResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.generate_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateCertResponse', pipeline_response) + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate'} # type: ignore + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace_async async def get_extended_information( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - async def _install_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + async def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -815,165 +1063,172 @@ async def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def begin_install_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._install_updates_initial( + raw_result = await self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + + @distributed_trace_async async def get_network_settings( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.NetworkSettings": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - async def _scan_for_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + async def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -983,113 +1238,126 @@ async def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + @distributed_trace_async async def begin_scan_for_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._scan_for_updates_initial( + raw_result = await self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - async def _create_or_update_security_settings_initial( + async def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1099,265 +1367,493 @@ async def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload async def begin_create_or_update_security_settings( self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2020_12_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2020_12_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_security_settings_initial( + raw_result = await self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async async def update_extended_information( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDeviceExtendedInfoPatch", - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The patch object. + :param parameters: The patch object. Is either a model type or a IO type. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfoPatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDeviceExtendedInfoPatch') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation'} # type: ignore + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace_async async def get_update_summary( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.UpdateSummary": - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload async def upload_certificate( self, device_name: str, resource_group_name: str, - parameters: "_models.UploadCertificateRequest", - **kwargs - ) -> "_models.UploadCertificateResponse": + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_jobs_operations.py index 792da56690ad..068d4465b3fe 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class JobsOperations: - """JobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_monitoring_config_operations.py index 23fd343f2ac8..be8e790787b0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_monitoring_config_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_monitoring_config_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._monitoring_config_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringConfigOperations: - """MonitoringConfigOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.MonitoringMetricConfigurationList"]: + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MonitoringMetricConfiguration"]: """Lists metric configurations in a role. Lists metric configurations in a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 MonitoringMetricConfigurationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfigurationList', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,116 +155,130 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + @distributed_trace_async async def get( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.MonitoringMetricConfiguration": + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: """Gets a metric configuration of a role. Gets a metric configuration of a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringMetricConfiguration, or the result of cls(response) + :return: MonitoringMetricConfiguration or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } async def _create_or_update_initial( self, device_name: str, role_name: str, resource_group_name: str, - monitoring_metric_configuration: "_models.MonitoringMetricConfiguration", - **kwargs - ) -> Optional["_models.MonitoringMetricConfiguration"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MonitoringMetricConfiguration"]] + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(monitoring_metric_configuration, 'MonitoringMetricConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -236,127 +287,223 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload async def begin_create_or_update( self, device_name: str, role_name: str, resource_group_name: str, - monitoring_metric_configuration: "_models.MonitoringMetricConfiguration", - **kwargs - ) -> AsyncLROPoller["_models.MonitoringMetricConfiguration"]: + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: """Creates a new metric configuration or updates an existing one for a role. Creates a new metric configuration or updates an existing one for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param monitoring_metric_configuration: The metric configuration. - :type monitoring_metric_configuration: ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, monitoring_metric_configuration=monitoring_metric_configuration, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) - + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -366,75 +513,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """deletes a new metric configuration for a role. deletes a new metric configuration for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_nodes_operations.py index fb78384ebf77..09aa348995b8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._nodes_operations import build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NodesOperations: - """NodesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.NodeList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +141,8 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_operations.py index 9b025645c727..64982550fa50 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,126 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.OperationsList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +134,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_operations_status_operations.py index 7b3bd3020a35..5319127829b8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations_status_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsStatusOperations: - """OperationsStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_orders_operations.py index 13461d449752..51adb5532310 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._orders_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_list_dc_access_code_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OrdersOperations: - """OrdersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.OrderList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,110 +152,119 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Order": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } async def _create_or_update_initial( - self, - device_name: str, - resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> Optional["_models.Order"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -226,120 +273,200 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> AsyncLROPoller["_models.Order"]: + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2020_12_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2020_12_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -349,130 +476,135 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + @distributed_trace_async async def list_dc_access_code( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DCAccessCode": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DCAccessCode: """Gets the DCAccess Code. Gets the DCAccess Code. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DCAccessCode, or the result of cls(response) + :return: DCAccessCode or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DCAccessCode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DCAccessCode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_dc_access_code.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DCAccessCode', pipeline_response) + deserialized = self._deserialize("DCAccessCode", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_dc_access_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode'} # type: ignore + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_roles_operations.py index c48fb03eb036..ecc732bd6542 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._roles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RolesOperations: - """RolesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.RoleList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Role": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> Optional["_models.Role"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +272,203 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> AsyncLROPoller["_models.Role"]: + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2020_12_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2020_12_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +478,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_shares_operations.py index 2dd990265729..9e0c738d5967 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._shares_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SharesOperations: - """SharesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ShareList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +152,123 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Share": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> Optional["_models.Share"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +277,209 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> AsyncLROPoller["_models.Share"]: + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2020_12_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2020_12_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,112 +489,112 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -477,75 +604,76 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_storage_account_credentials_operations.py index 3289fffa87df..6e9e381081d4 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_account_credentials_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountCredentialsOperations: - """StorageAccountCredentialsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountCredentialList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,114 +152,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccountCredential": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> Optional["_models.StorageAccountCredential"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -230,125 +282,217 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccountCredential"]: + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,73 +502,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_storage_accounts_operations.py index 6cc6cd15314f..31a43deedd17 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_accounts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountsOperations: - """StorageAccountsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +151,130 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccount": + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } async def _create_or_update_initial( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +283,221 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccount"]: + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -362,73 +507,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_triggers_operations.py index 9eab91ee9da8..7366f1118a76 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._triggers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TriggersOperations: - """TriggersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.TriggerList"]: + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +153,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Trigger": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> Optional["_models.Trigger"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,125 +276,206 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> AsyncLROPoller["_models.Trigger"]: + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2020_12_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Trigger or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Trigger or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2020_12_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +485,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_users_operations.py index b3666cb2e9c5..4f1721e0f1af 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/aio/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UsersOperations: - """UsersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.aio.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.UserList"]: + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='Type eq :code:``' to filter on user type property. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,114 +153,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.User": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - user: "_models.User", - **kwargs - ) -> Optional["_models.User"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,126 +276,206 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - user: "_models.User", - **kwargs - ) -> AsyncLROPoller["_models.User"]: + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2020_12_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2020_12_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +485,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/__init__.py index dbf0ba0fe2be..d5d8caecff3e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/__init__.py @@ -6,482 +6,364 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARMBaseModel - from ._models_py3 import Addon - from ._models_py3 import AddonList - from ._models_py3 import Address - from ._models_py3 import Alert - from ._models_py3 import AlertErrorDetails - from ._models_py3 import AlertList - from ._models_py3 import ArcAddon - from ._models_py3 import AsymmetricEncryptedSecret - from ._models_py3 import Authentication - from ._models_py3 import AzureContainerInfo - from ._models_py3 import BandwidthSchedule - from ._models_py3 import BandwidthSchedulesList - from ._models_py3 import ClientAccessRight - from ._models_py3 import CloudEdgeManagementRole - from ._models_py3 import CloudErrorBody - from ._models_py3 import CniConfig - from ._models_py3 import ComputeResource - from ._models_py3 import ContactDetails - from ._models_py3 import Container - from ._models_py3 import ContainerList - from ._models_py3 import DCAccessCode - from ._models_py3 import DataBoxEdgeDevice - from ._models_py3 import DataBoxEdgeDeviceExtendedInfo - from ._models_py3 import DataBoxEdgeDeviceExtendedInfoPatch - from ._models_py3 import DataBoxEdgeDeviceList - from ._models_py3 import DataBoxEdgeDevicePatch - from ._models_py3 import DataBoxEdgeMoveRequest - from ._models_py3 import DataBoxEdgeSku - from ._models_py3 import DataBoxEdgeSkuList - from ._models_py3 import DeviceSecrets - from ._models_py3 import EdgeProfile - from ._models_py3 import EdgeProfilePatch - from ._models_py3 import EdgeProfileSubscription - from ._models_py3 import EdgeProfileSubscriptionPatch - from ._models_py3 import EtcdInfo - from ._models_py3 import FileEventTrigger - from ._models_py3 import FileSourceInfo - from ._models_py3 import GenerateCertResponse - from ._models_py3 import ImageRepositoryCredential - from ._models_py3 import IoTAddon - from ._models_py3 import IoTDeviceInfo - from ._models_py3 import IoTEdgeAgentInfo - from ._models_py3 import IoTRole - from ._models_py3 import Ipv4Config - from ._models_py3 import Ipv6Config - from ._models_py3 import Job - from ._models_py3 import JobErrorDetails - from ._models_py3 import JobErrorItem - from ._models_py3 import KubernetesClusterInfo - from ._models_py3 import KubernetesIPConfiguration - from ._models_py3 import KubernetesRole - from ._models_py3 import KubernetesRoleCompute - from ._models_py3 import KubernetesRoleNetwork - from ._models_py3 import KubernetesRoleResources - from ._models_py3 import KubernetesRoleStorage - from ._models_py3 import KubernetesRoleStorageClassInfo - from ._models_py3 import LoadBalancerConfig - from ._models_py3 import MECRole - from ._models_py3 import MetricConfiguration - from ._models_py3 import MetricCounter - from ._models_py3 import MetricCounterSet - from ._models_py3 import MetricDimension - from ._models_py3 import MetricDimensionV1 - from ._models_py3 import MetricSpecificationV1 - from ._models_py3 import MonitoringMetricConfiguration - from ._models_py3 import MonitoringMetricConfigurationList - from ._models_py3 import MountPointMap - from ._models_py3 import NetworkAdapter - from ._models_py3 import NetworkAdapterPosition - from ._models_py3 import NetworkSettings - from ._models_py3 import Node - from ._models_py3 import NodeInfo - from ._models_py3 import NodeList - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import Order - from ._models_py3 import OrderList - from ._models_py3 import OrderStatus - from ._models_py3 import PeriodicTimerEventTrigger - from ._models_py3 import PeriodicTimerSourceInfo - from ._models_py3 import RefreshDetails - from ._models_py3 import ResourceIdentity - from ._models_py3 import ResourceMoveDetails - from ._models_py3 import ResourceTypeSku - from ._models_py3 import Role - from ._models_py3 import RoleList - from ._models_py3 import RoleSinkInfo - from ._models_py3 import Secret - from ._models_py3 import SecuritySettings - from ._models_py3 import ServiceSpecification - from ._models_py3 import Share - from ._models_py3 import ShareAccessRight - from ._models_py3 import ShareList - from ._models_py3 import Sku - from ._models_py3 import SkuCapability - from ._models_py3 import SkuCost - from ._models_py3 import SkuInformation - from ._models_py3 import SkuInformationList - from ._models_py3 import SkuLocationInfo - from ._models_py3 import StorageAccount - from ._models_py3 import StorageAccountCredential - from ._models_py3 import StorageAccountCredentialList - from ._models_py3 import StorageAccountList - from ._models_py3 import SubscriptionRegisteredFeatures - from ._models_py3 import SymmetricKey - from ._models_py3 import SystemData - from ._models_py3 import TrackingInfo - from ._models_py3 import Trigger - from ._models_py3 import TriggerList - from ._models_py3 import UpdateDownloadProgress - from ._models_py3 import UpdateInstallProgress - from ._models_py3 import UpdateSummary - from ._models_py3 import UploadCertificateRequest - from ._models_py3 import UploadCertificateResponse - from ._models_py3 import User - from ._models_py3 import UserAccessRight - from ._models_py3 import UserList -except (SyntaxError, ImportError): - from ._models import ARMBaseModel # type: ignore - from ._models import Addon # type: ignore - from ._models import AddonList # type: ignore - from ._models import Address # type: ignore - from ._models import Alert # type: ignore - from ._models import AlertErrorDetails # type: ignore - from ._models import AlertList # type: ignore - from ._models import ArcAddon # type: ignore - from ._models import AsymmetricEncryptedSecret # type: ignore - from ._models import Authentication # type: ignore - from ._models import AzureContainerInfo # type: ignore - from ._models import BandwidthSchedule # type: ignore - from ._models import BandwidthSchedulesList # type: ignore - from ._models import ClientAccessRight # type: ignore - from ._models import CloudEdgeManagementRole # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import CniConfig # type: ignore - from ._models import ComputeResource # type: ignore - from ._models import ContactDetails # type: ignore - from ._models import Container # type: ignore - from ._models import ContainerList # type: ignore - from ._models import DCAccessCode # type: ignore - from ._models import DataBoxEdgeDevice # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfo # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfoPatch # type: ignore - from ._models import DataBoxEdgeDeviceList # type: ignore - from ._models import DataBoxEdgeDevicePatch # type: ignore - from ._models import DataBoxEdgeMoveRequest # type: ignore - from ._models import DataBoxEdgeSku # type: ignore - from ._models import DataBoxEdgeSkuList # type: ignore - from ._models import DeviceSecrets # type: ignore - from ._models import EdgeProfile # type: ignore - from ._models import EdgeProfilePatch # type: ignore - from ._models import EdgeProfileSubscription # type: ignore - from ._models import EdgeProfileSubscriptionPatch # type: ignore - from ._models import EtcdInfo # type: ignore - from ._models import FileEventTrigger # type: ignore - from ._models import FileSourceInfo # type: ignore - from ._models import GenerateCertResponse # type: ignore - from ._models import ImageRepositoryCredential # type: ignore - from ._models import IoTAddon # type: ignore - from ._models import IoTDeviceInfo # type: ignore - from ._models import IoTEdgeAgentInfo # type: ignore - from ._models import IoTRole # type: ignore - from ._models import Ipv4Config # type: ignore - from ._models import Ipv6Config # type: ignore - from ._models import Job # type: ignore - from ._models import JobErrorDetails # type: ignore - from ._models import JobErrorItem # type: ignore - from ._models import KubernetesClusterInfo # type: ignore - from ._models import KubernetesIPConfiguration # type: ignore - from ._models import KubernetesRole # type: ignore - from ._models import KubernetesRoleCompute # type: ignore - from ._models import KubernetesRoleNetwork # type: ignore - from ._models import KubernetesRoleResources # type: ignore - from ._models import KubernetesRoleStorage # type: ignore - from ._models import KubernetesRoleStorageClassInfo # type: ignore - from ._models import LoadBalancerConfig # type: ignore - from ._models import MECRole # type: ignore - from ._models import MetricConfiguration # type: ignore - from ._models import MetricCounter # type: ignore - from ._models import MetricCounterSet # type: ignore - from ._models import MetricDimension # type: ignore - from ._models import MetricDimensionV1 # type: ignore - from ._models import MetricSpecificationV1 # type: ignore - from ._models import MonitoringMetricConfiguration # type: ignore - from ._models import MonitoringMetricConfigurationList # type: ignore - from ._models import MountPointMap # type: ignore - from ._models import NetworkAdapter # type: ignore - from ._models import NetworkAdapterPosition # type: ignore - from ._models import NetworkSettings # type: ignore - from ._models import Node # type: ignore - from ._models import NodeInfo # type: ignore - from ._models import NodeList # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import Order # type: ignore - from ._models import OrderList # type: ignore - from ._models import OrderStatus # type: ignore - from ._models import PeriodicTimerEventTrigger # type: ignore - from ._models import PeriodicTimerSourceInfo # type: ignore - from ._models import RefreshDetails # type: ignore - from ._models import ResourceIdentity # type: ignore - from ._models import ResourceMoveDetails # type: ignore - from ._models import ResourceTypeSku # type: ignore - from ._models import Role # type: ignore - from ._models import RoleList # type: ignore - from ._models import RoleSinkInfo # type: ignore - from ._models import Secret # type: ignore - from ._models import SecuritySettings # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Share # type: ignore - from ._models import ShareAccessRight # type: ignore - from ._models import ShareList # type: ignore - from ._models import Sku # type: ignore - from ._models import SkuCapability # type: ignore - from ._models import SkuCost # type: ignore - from ._models import SkuInformation # type: ignore - from ._models import SkuInformationList # type: ignore - from ._models import SkuLocationInfo # type: ignore - from ._models import StorageAccount # type: ignore - from ._models import StorageAccountCredential # type: ignore - from ._models import StorageAccountCredentialList # type: ignore - from ._models import StorageAccountList # type: ignore - from ._models import SubscriptionRegisteredFeatures # type: ignore - from ._models import SymmetricKey # type: ignore - from ._models import SystemData # type: ignore - from ._models import TrackingInfo # type: ignore - from ._models import Trigger # type: ignore - from ._models import TriggerList # type: ignore - from ._models import UpdateDownloadProgress # type: ignore - from ._models import UpdateInstallProgress # type: ignore - from ._models import UpdateSummary # type: ignore - from ._models import UploadCertificateRequest # type: ignore - from ._models import UploadCertificateResponse # type: ignore - from ._models import User # type: ignore - from ._models import UserAccessRight # type: ignore - from ._models import UserList # type: ignore +from ._models_py3 import ARMBaseModel +from ._models_py3 import Addon +from ._models_py3 import AddonList +from ._models_py3 import Address +from ._models_py3 import Alert +from ._models_py3 import AlertErrorDetails +from ._models_py3 import AlertList +from ._models_py3 import ArcAddon +from ._models_py3 import AsymmetricEncryptedSecret +from ._models_py3 import Authentication +from ._models_py3 import AzureContainerInfo +from ._models_py3 import BandwidthSchedule +from ._models_py3 import BandwidthSchedulesList +from ._models_py3 import ClientAccessRight +from ._models_py3 import CloudEdgeManagementRole +from ._models_py3 import CloudErrorBody +from ._models_py3 import CniConfig +from ._models_py3 import ComputeResource +from ._models_py3 import ContactDetails +from ._models_py3 import Container +from ._models_py3 import ContainerList +from ._models_py3 import DCAccessCode +from ._models_py3 import DataBoxEdgeDevice +from ._models_py3 import DataBoxEdgeDeviceExtendedInfo +from ._models_py3 import DataBoxEdgeDeviceExtendedInfoPatch +from ._models_py3 import DataBoxEdgeDeviceList +from ._models_py3 import DataBoxEdgeDevicePatch +from ._models_py3 import DataBoxEdgeMoveRequest +from ._models_py3 import DataBoxEdgeSku +from ._models_py3 import DataBoxEdgeSkuList +from ._models_py3 import DeviceSecrets +from ._models_py3 import EdgeProfile +from ._models_py3 import EdgeProfilePatch +from ._models_py3 import EdgeProfileSubscription +from ._models_py3 import EdgeProfileSubscriptionPatch +from ._models_py3 import EtcdInfo +from ._models_py3 import FileEventTrigger +from ._models_py3 import FileSourceInfo +from ._models_py3 import GenerateCertResponse +from ._models_py3 import ImageRepositoryCredential +from ._models_py3 import IoTAddon +from ._models_py3 import IoTDeviceInfo +from ._models_py3 import IoTEdgeAgentInfo +from ._models_py3 import IoTRole +from ._models_py3 import Ipv4Config +from ._models_py3 import Ipv6Config +from ._models_py3 import Job +from ._models_py3 import JobErrorDetails +from ._models_py3 import JobErrorItem +from ._models_py3 import KubernetesClusterInfo +from ._models_py3 import KubernetesIPConfiguration +from ._models_py3 import KubernetesRole +from ._models_py3 import KubernetesRoleCompute +from ._models_py3 import KubernetesRoleNetwork +from ._models_py3 import KubernetesRoleResources +from ._models_py3 import KubernetesRoleStorage +from ._models_py3 import KubernetesRoleStorageClassInfo +from ._models_py3 import LoadBalancerConfig +from ._models_py3 import MECRole +from ._models_py3 import MetricConfiguration +from ._models_py3 import MetricCounter +from ._models_py3 import MetricCounterSet +from ._models_py3 import MetricDimension +from ._models_py3 import MetricDimensionV1 +from ._models_py3 import MetricSpecificationV1 +from ._models_py3 import MonitoringMetricConfiguration +from ._models_py3 import MonitoringMetricConfigurationList +from ._models_py3 import MountPointMap +from ._models_py3 import NetworkAdapter +from ._models_py3 import NetworkAdapterPosition +from ._models_py3 import NetworkSettings +from ._models_py3 import Node +from ._models_py3 import NodeInfo +from ._models_py3 import NodeList +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import Order +from ._models_py3 import OrderList +from ._models_py3 import OrderStatus +from ._models_py3 import PeriodicTimerEventTrigger +from ._models_py3 import PeriodicTimerSourceInfo +from ._models_py3 import RefreshDetails +from ._models_py3 import ResourceIdentity +from ._models_py3 import ResourceMoveDetails +from ._models_py3 import ResourceTypeSku +from ._models_py3 import Role +from ._models_py3 import RoleList +from ._models_py3 import RoleSinkInfo +from ._models_py3 import Secret +from ._models_py3 import SecuritySettings +from ._models_py3 import ServiceSpecification +from ._models_py3 import Share +from ._models_py3 import ShareAccessRight +from ._models_py3 import ShareList +from ._models_py3 import Sku +from ._models_py3 import SkuCapability +from ._models_py3 import SkuCost +from ._models_py3 import SkuInformation +from ._models_py3 import SkuInformationList +from ._models_py3 import SkuLocationInfo +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCredential +from ._models_py3 import StorageAccountCredentialList +from ._models_py3 import StorageAccountList +from ._models_py3 import SubscriptionRegisteredFeatures +from ._models_py3 import SymmetricKey +from ._models_py3 import SystemData +from ._models_py3 import TrackingInfo +from ._models_py3 import Trigger +from ._models_py3 import TriggerList +from ._models_py3 import UpdateDownloadProgress +from ._models_py3 import UpdateInstallProgress +from ._models_py3 import UpdateSummary +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UploadCertificateResponse +from ._models_py3 import User +from ._models_py3 import UserAccessRight +from ._models_py3 import UserList -from ._data_box_edge_management_client_enums import ( - AccountType, - AddonState, - AddonType, - AlertSeverity, - AuthenticationType, - AzureContainerDataFormat, - ClientPermissionType, - ContainerStatus, - CreatedByType, - DataBoxEdgeDeviceKind, - DataBoxEdgeDeviceStatus, - DataPolicy, - DayOfWeek, - DeviceType, - DownloadPhase, - EncryptionAlgorithm, - HostPlatformType, - InstallRebootBehavior, - JobStatus, - JobType, - KeyVaultSyncStatus, - KubernetesNodeType, - KubernetesState, - MetricAggregationType, - MetricCategory, - MetricUnit, - MonitoringStatus, - MountType, - MsiIdentityType, - NetworkAdapterDHCPStatus, - NetworkAdapterRDMAStatus, - NetworkAdapterStatus, - NetworkGroup, - NodeStatus, - OrderState, - PlatformType, - PosixComplianceStatus, - ResourceMoveStatus, - RoleStatus, - RoleTypes, - SSLStatus, - ShareAccessProtocol, - ShareAccessType, - ShareStatus, - ShipmentType, - SkuAvailability, - SkuName, - SkuSignupOption, - SkuTier, - SkuVersion, - StorageAccountStatus, - SubscriptionState, - TimeGrain, - TriggerEventType, - UpdateOperation, - UpdateOperationStage, - UserType, -) +from ._data_box_edge_management_client_enums import AccountType +from ._data_box_edge_management_client_enums import AddonState +from ._data_box_edge_management_client_enums import AddonType +from ._data_box_edge_management_client_enums import AlertSeverity +from ._data_box_edge_management_client_enums import AuthenticationType +from ._data_box_edge_management_client_enums import AzureContainerDataFormat +from ._data_box_edge_management_client_enums import ClientPermissionType +from ._data_box_edge_management_client_enums import ContainerStatus +from ._data_box_edge_management_client_enums import CreatedByType +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceKind +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceStatus +from ._data_box_edge_management_client_enums import DataPolicy +from ._data_box_edge_management_client_enums import DayOfWeek +from ._data_box_edge_management_client_enums import DeviceType +from ._data_box_edge_management_client_enums import DownloadPhase +from ._data_box_edge_management_client_enums import EncryptionAlgorithm +from ._data_box_edge_management_client_enums import HostPlatformType +from ._data_box_edge_management_client_enums import InstallRebootBehavior +from ._data_box_edge_management_client_enums import JobStatus +from ._data_box_edge_management_client_enums import JobType +from ._data_box_edge_management_client_enums import KeyVaultSyncStatus +from ._data_box_edge_management_client_enums import KubernetesNodeType +from ._data_box_edge_management_client_enums import KubernetesState +from ._data_box_edge_management_client_enums import MetricAggregationType +from ._data_box_edge_management_client_enums import MetricCategory +from ._data_box_edge_management_client_enums import MetricUnit +from ._data_box_edge_management_client_enums import MonitoringStatus +from ._data_box_edge_management_client_enums import MountType +from ._data_box_edge_management_client_enums import MsiIdentityType +from ._data_box_edge_management_client_enums import NetworkAdapterDHCPStatus +from ._data_box_edge_management_client_enums import NetworkAdapterRDMAStatus +from ._data_box_edge_management_client_enums import NetworkAdapterStatus +from ._data_box_edge_management_client_enums import NetworkGroup +from ._data_box_edge_management_client_enums import NodeStatus +from ._data_box_edge_management_client_enums import OrderState +from ._data_box_edge_management_client_enums import PlatformType +from ._data_box_edge_management_client_enums import PosixComplianceStatus +from ._data_box_edge_management_client_enums import ResourceMoveStatus +from ._data_box_edge_management_client_enums import RoleStatus +from ._data_box_edge_management_client_enums import RoleTypes +from ._data_box_edge_management_client_enums import SSLStatus +from ._data_box_edge_management_client_enums import ShareAccessProtocol +from ._data_box_edge_management_client_enums import ShareAccessType +from ._data_box_edge_management_client_enums import ShareStatus +from ._data_box_edge_management_client_enums import ShipmentType +from ._data_box_edge_management_client_enums import SkuAvailability +from ._data_box_edge_management_client_enums import SkuName +from ._data_box_edge_management_client_enums import SkuSignupOption +from ._data_box_edge_management_client_enums import SkuTier +from ._data_box_edge_management_client_enums import SkuVersion +from ._data_box_edge_management_client_enums import StorageAccountStatus +from ._data_box_edge_management_client_enums import SubscriptionState +from ._data_box_edge_management_client_enums import TimeGrain +from ._data_box_edge_management_client_enums import TriggerEventType +from ._data_box_edge_management_client_enums import UpdateOperation +from ._data_box_edge_management_client_enums import UpdateOperationStage +from ._data_box_edge_management_client_enums import UserType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ARMBaseModel', - 'Addon', - 'AddonList', - 'Address', - 'Alert', - 'AlertErrorDetails', - 'AlertList', - 'ArcAddon', - 'AsymmetricEncryptedSecret', - 'Authentication', - 'AzureContainerInfo', - 'BandwidthSchedule', - 'BandwidthSchedulesList', - 'ClientAccessRight', - 'CloudEdgeManagementRole', - 'CloudErrorBody', - 'CniConfig', - 'ComputeResource', - 'ContactDetails', - 'Container', - 'ContainerList', - 'DCAccessCode', - 'DataBoxEdgeDevice', - 'DataBoxEdgeDeviceExtendedInfo', - 'DataBoxEdgeDeviceExtendedInfoPatch', - 'DataBoxEdgeDeviceList', - 'DataBoxEdgeDevicePatch', - 'DataBoxEdgeMoveRequest', - 'DataBoxEdgeSku', - 'DataBoxEdgeSkuList', - 'DeviceSecrets', - 'EdgeProfile', - 'EdgeProfilePatch', - 'EdgeProfileSubscription', - 'EdgeProfileSubscriptionPatch', - 'EtcdInfo', - 'FileEventTrigger', - 'FileSourceInfo', - 'GenerateCertResponse', - 'ImageRepositoryCredential', - 'IoTAddon', - 'IoTDeviceInfo', - 'IoTEdgeAgentInfo', - 'IoTRole', - 'Ipv4Config', - 'Ipv6Config', - 'Job', - 'JobErrorDetails', - 'JobErrorItem', - 'KubernetesClusterInfo', - 'KubernetesIPConfiguration', - 'KubernetesRole', - 'KubernetesRoleCompute', - 'KubernetesRoleNetwork', - 'KubernetesRoleResources', - 'KubernetesRoleStorage', - 'KubernetesRoleStorageClassInfo', - 'LoadBalancerConfig', - 'MECRole', - 'MetricConfiguration', - 'MetricCounter', - 'MetricCounterSet', - 'MetricDimension', - 'MetricDimensionV1', - 'MetricSpecificationV1', - 'MonitoringMetricConfiguration', - 'MonitoringMetricConfigurationList', - 'MountPointMap', - 'NetworkAdapter', - 'NetworkAdapterPosition', - 'NetworkSettings', - 'Node', - 'NodeInfo', - 'NodeList', - 'Operation', - 'OperationDisplay', - 'OperationsList', - 'Order', - 'OrderList', - 'OrderStatus', - 'PeriodicTimerEventTrigger', - 'PeriodicTimerSourceInfo', - 'RefreshDetails', - 'ResourceIdentity', - 'ResourceMoveDetails', - 'ResourceTypeSku', - 'Role', - 'RoleList', - 'RoleSinkInfo', - 'Secret', - 'SecuritySettings', - 'ServiceSpecification', - 'Share', - 'ShareAccessRight', - 'ShareList', - 'Sku', - 'SkuCapability', - 'SkuCost', - 'SkuInformation', - 'SkuInformationList', - 'SkuLocationInfo', - 'StorageAccount', - 'StorageAccountCredential', - 'StorageAccountCredentialList', - 'StorageAccountList', - 'SubscriptionRegisteredFeatures', - 'SymmetricKey', - 'SystemData', - 'TrackingInfo', - 'Trigger', - 'TriggerList', - 'UpdateDownloadProgress', - 'UpdateInstallProgress', - 'UpdateSummary', - 'UploadCertificateRequest', - 'UploadCertificateResponse', - 'User', - 'UserAccessRight', - 'UserList', - 'AccountType', - 'AddonState', - 'AddonType', - 'AlertSeverity', - 'AuthenticationType', - 'AzureContainerDataFormat', - 'ClientPermissionType', - 'ContainerStatus', - 'CreatedByType', - 'DataBoxEdgeDeviceKind', - 'DataBoxEdgeDeviceStatus', - 'DataPolicy', - 'DayOfWeek', - 'DeviceType', - 'DownloadPhase', - 'EncryptionAlgorithm', - 'HostPlatformType', - 'InstallRebootBehavior', - 'JobStatus', - 'JobType', - 'KeyVaultSyncStatus', - 'KubernetesNodeType', - 'KubernetesState', - 'MetricAggregationType', - 'MetricCategory', - 'MetricUnit', - 'MonitoringStatus', - 'MountType', - 'MsiIdentityType', - 'NetworkAdapterDHCPStatus', - 'NetworkAdapterRDMAStatus', - 'NetworkAdapterStatus', - 'NetworkGroup', - 'NodeStatus', - 'OrderState', - 'PlatformType', - 'PosixComplianceStatus', - 'ResourceMoveStatus', - 'RoleStatus', - 'RoleTypes', - 'SSLStatus', - 'ShareAccessProtocol', - 'ShareAccessType', - 'ShareStatus', - 'ShipmentType', - 'SkuAvailability', - 'SkuName', - 'SkuSignupOption', - 'SkuTier', - 'SkuVersion', - 'StorageAccountStatus', - 'SubscriptionState', - 'TimeGrain', - 'TriggerEventType', - 'UpdateOperation', - 'UpdateOperationStage', - 'UserType', + "ARMBaseModel", + "Addon", + "AddonList", + "Address", + "Alert", + "AlertErrorDetails", + "AlertList", + "ArcAddon", + "AsymmetricEncryptedSecret", + "Authentication", + "AzureContainerInfo", + "BandwidthSchedule", + "BandwidthSchedulesList", + "ClientAccessRight", + "CloudEdgeManagementRole", + "CloudErrorBody", + "CniConfig", + "ComputeResource", + "ContactDetails", + "Container", + "ContainerList", + "DCAccessCode", + "DataBoxEdgeDevice", + "DataBoxEdgeDeviceExtendedInfo", + "DataBoxEdgeDeviceExtendedInfoPatch", + "DataBoxEdgeDeviceList", + "DataBoxEdgeDevicePatch", + "DataBoxEdgeMoveRequest", + "DataBoxEdgeSku", + "DataBoxEdgeSkuList", + "DeviceSecrets", + "EdgeProfile", + "EdgeProfilePatch", + "EdgeProfileSubscription", + "EdgeProfileSubscriptionPatch", + "EtcdInfo", + "FileEventTrigger", + "FileSourceInfo", + "GenerateCertResponse", + "ImageRepositoryCredential", + "IoTAddon", + "IoTDeviceInfo", + "IoTEdgeAgentInfo", + "IoTRole", + "Ipv4Config", + "Ipv6Config", + "Job", + "JobErrorDetails", + "JobErrorItem", + "KubernetesClusterInfo", + "KubernetesIPConfiguration", + "KubernetesRole", + "KubernetesRoleCompute", + "KubernetesRoleNetwork", + "KubernetesRoleResources", + "KubernetesRoleStorage", + "KubernetesRoleStorageClassInfo", + "LoadBalancerConfig", + "MECRole", + "MetricConfiguration", + "MetricCounter", + "MetricCounterSet", + "MetricDimension", + "MetricDimensionV1", + "MetricSpecificationV1", + "MonitoringMetricConfiguration", + "MonitoringMetricConfigurationList", + "MountPointMap", + "NetworkAdapter", + "NetworkAdapterPosition", + "NetworkSettings", + "Node", + "NodeInfo", + "NodeList", + "Operation", + "OperationDisplay", + "OperationsList", + "Order", + "OrderList", + "OrderStatus", + "PeriodicTimerEventTrigger", + "PeriodicTimerSourceInfo", + "RefreshDetails", + "ResourceIdentity", + "ResourceMoveDetails", + "ResourceTypeSku", + "Role", + "RoleList", + "RoleSinkInfo", + "Secret", + "SecuritySettings", + "ServiceSpecification", + "Share", + "ShareAccessRight", + "ShareList", + "Sku", + "SkuCapability", + "SkuCost", + "SkuInformation", + "SkuInformationList", + "SkuLocationInfo", + "StorageAccount", + "StorageAccountCredential", + "StorageAccountCredentialList", + "StorageAccountList", + "SubscriptionRegisteredFeatures", + "SymmetricKey", + "SystemData", + "TrackingInfo", + "Trigger", + "TriggerList", + "UpdateDownloadProgress", + "UpdateInstallProgress", + "UpdateSummary", + "UploadCertificateRequest", + "UploadCertificateResponse", + "User", + "UserAccessRight", + "UserList", + "AccountType", + "AddonState", + "AddonType", + "AlertSeverity", + "AuthenticationType", + "AzureContainerDataFormat", + "ClientPermissionType", + "ContainerStatus", + "CreatedByType", + "DataBoxEdgeDeviceKind", + "DataBoxEdgeDeviceStatus", + "DataPolicy", + "DayOfWeek", + "DeviceType", + "DownloadPhase", + "EncryptionAlgorithm", + "HostPlatformType", + "InstallRebootBehavior", + "JobStatus", + "JobType", + "KeyVaultSyncStatus", + "KubernetesNodeType", + "KubernetesState", + "MetricAggregationType", + "MetricCategory", + "MetricUnit", + "MonitoringStatus", + "MountType", + "MsiIdentityType", + "NetworkAdapterDHCPStatus", + "NetworkAdapterRDMAStatus", + "NetworkAdapterStatus", + "NetworkGroup", + "NodeStatus", + "OrderState", + "PlatformType", + "PosixComplianceStatus", + "ResourceMoveStatus", + "RoleStatus", + "RoleTypes", + "SSLStatus", + "ShareAccessProtocol", + "ShareAccessType", + "ShareStatus", + "ShipmentType", + "SkuAvailability", + "SkuName", + "SkuSignupOption", + "SkuTier", + "SkuVersion", + "StorageAccountStatus", + "SubscriptionState", + "TimeGrain", + "TriggerEventType", + "UpdateOperation", + "UpdateOperationStage", + "UserType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_data_box_edge_management_client_enums.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_data_box_edge_management_client_enums.py index 8bf52f24f0f2..f4e5e69f2524 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_data_box_edge_management_client_enums.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_data_box_edge_management_client_enums.py @@ -6,36 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of storage accessed on the storage account. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of storage accessed on the storage account.""" GENERAL_PURPOSE_STORAGE = "GeneralPurposeStorage" BLOB_STORAGE = "BlobStorage" -class AddonState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Addon Provisioning State - """ + +class AddonState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon Provisioning State.""" INVALID = "Invalid" CREATING = "Creating" @@ -45,47 +28,47 @@ class AddonState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETING = "Deleting" -class AddonType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Addon type. - """ + +class AddonType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon type.""" IOT_EDGE = "IotEdge" ARC_FOR_KUBERNETES = "ArcForKubernetes" -class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the alert. - """ + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert.""" INFORMATIONAL = "Informational" WARNING = "Warning" CRITICAL = "Critical" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The authentication type. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication type.""" INVALID = "Invalid" AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" -class AzureContainerDataFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Storage format used for the file represented by the share. - """ + +class AzureContainerDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage format used for the file represented by the share.""" BLOCK_BLOB = "BlockBlob" PAGE_BLOB = "PageBlob" AZURE_FILE = "AzureFile" -class ClientPermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed for the client. - """ + +class ClientPermissionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed for the client.""" NO_ACCESS = "NoAccess" READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the container. - """ + +class ContainerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the container.""" OK = "OK" OFFLINE = "Offline" @@ -93,27 +76,27 @@ class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DataBoxEdgeDeviceKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The etag for the devices. - """ + +class DataBoxEdgeDeviceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The etag for the devices.""" AZURE_DATA_BOX_GATEWAY = "AzureDataBoxGateway" AZURE_STACK_EDGE = "AzureStackEdge" AZURE_STACK_HUB = "AzureStackHub" AZURE_MODULAR_DATA_CENTRE = "AzureModularDataCentre" -class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the Data Box Edge/Gateway device. - """ + +class DataBoxEdgeDeviceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the Data Box Edge/Gateway device.""" READY_TO_SETUP = "ReadyToSetup" ONLINE = "Online" @@ -123,14 +106,16 @@ class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum PARTIALLY_DISCONNECTED = "PartiallyDisconnected" MAINTENANCE = "Maintenance" -class DataPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Data policy of the share. - """ + +class DataPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data policy of the share.""" CLOUD = "Cloud" LOCAL = "Local" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -140,47 +125,47 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DeviceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the Data Box Edge/Gateway device. - """ + +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the Data Box Edge/Gateway device.""" DATA_BOX_EDGE_DEVICE = "DataBoxEdgeDevice" -class DownloadPhase(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The download phase. - """ + +class DownloadPhase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The download phase.""" UNKNOWN = "Unknown" INITIALIZING = "Initializing" DOWNLOADING = "Downloading" VERIFYING = "Verifying" -class EncryptionAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The algorithm used to encrypt "Value". - """ + +class EncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The algorithm used to encrypt "Value".""" NONE = "None" AES256 = "AES256" RSAES_PKCS1_V1_5 = "RSAES_PKCS1_v_1_5" -class HostPlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Platform where the runtime is hosted. - """ + +class HostPlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Platform where the runtime is hosted.""" KUBERNETES_CLUSTER = "KubernetesCluster" LINUX_VM = "LinuxVM" -class InstallRebootBehavior(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if updates are available and at least one of the updates needs a reboot. - """ + +class InstallRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if updates are available and at least one of the updates needs a reboot.""" NEVER_REBOOTS = "NeverReboots" REQUIRES_REBOOT = "RequiresReboot" REQUEST_REBOOT = "RequestReboot" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the job.""" INVALID = "Invalid" RUNNING = "Running" @@ -190,9 +175,9 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PAUSED = "Paused" SCHEDULED = "Scheduled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" INVALID = "Invalid" SCAN_FOR_UPDATES = "ScanForUpdates" @@ -204,7 +189,8 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESTORE = "Restore" TRIGGER_SUPPORT_PACKAGE = "TriggerSupportPackage" -class KeyVaultSyncStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class KeyVaultSyncStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """For changing or to initiate the resync to key-vault set the status to KeyVaultSyncPending, rest of the status will not be applicable. """ @@ -215,17 +201,17 @@ class KeyVaultSyncStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): KEY_VAULT_SYNC_PENDING = "KeyVaultSyncPending" KEY_VAULT_SYNCING = "KeyVaultSyncing" -class KubernetesNodeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Node type - Master/Worker - """ + +class KubernetesNodeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Node type - Master/Worker.""" INVALID = "Invalid" MASTER = "Master" WORKER = "Worker" -class KubernetesState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """State of Kubernetes deployment - """ + +class KubernetesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of Kubernetes deployment.""" INVALID = "Invalid" CREATING = "Creating" @@ -235,9 +221,9 @@ class KubernetesState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETING = "Deleting" -class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric aggregation type. - """ + +class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric aggregation type.""" NOT_SPECIFIED = "NotSpecified" NONE = "None" @@ -247,16 +233,16 @@ class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) TOTAL = "Total" COUNT = "Count" -class MetricCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric category. - """ + +class MetricCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric category.""" CAPACITY = "Capacity" TRANSACTION = "Transaction" -class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric units. - """ + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric units.""" NOT_SPECIFIED = "NotSpecified" PERCENT = "Percent" @@ -267,60 +253,60 @@ class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BYTES_PER_SECOND = "BytesPerSecond" COUNT_PER_SECOND = "CountPerSecond" -class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current monitoring status of the share. - """ + +class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current monitoring status of the share.""" ENABLED = "Enabled" DISABLED = "Disabled" -class MountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Mounting type. - """ + +class MountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Mounting type.""" VOLUME = "Volume" HOST_PATH = "HostPath" -class MsiIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Identity type - """ + +class MsiIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" -class NetworkAdapterDHCPStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter has DHCP enabled. - """ + +class NetworkAdapterDHCPStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter has DHCP enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" -class NetworkAdapterRDMAStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is RDMA capable. - """ + +class NetworkAdapterRDMAStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is RDMA capable.""" INCAPABLE = "Incapable" CAPABLE = "Capable" -class NetworkAdapterStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is valid. - """ + +class NetworkAdapterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is valid.""" INACTIVE = "Inactive" ACTIVE = "Active" -class NetworkGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The network group. - """ + +class NetworkGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network group.""" NONE = "None" NON_RDMA = "NonRDMA" RDMA = "RDMA" -class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the individual node - """ + +class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the individual node.""" UNKNOWN = "Unknown" UP = "Up" @@ -328,9 +314,9 @@ class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REBOOTING = "Rebooting" SHUTTING_DOWN = "ShuttingDown" -class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the order as per the allowed status types. - """ + +class OrderState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the order as per the allowed status types.""" UNTRACKED = "Untracked" AWAITING_FULFILMENT = "AwaitingFulfilment" @@ -350,37 +336,39 @@ class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PICKUP_COMPLETED = "PickupCompleted" AWAITING_DROP = "AwaitingDrop" -class PlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Host OS supported by the Arc addon. - """ + +class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host OS supported by the Arc addon.""" WINDOWS = "Windows" LINUX = "Linux" -class PosixComplianceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """If provisioned storage is posix compliant. - """ + +class PosixComplianceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """If provisioned storage is posix compliant.""" INVALID = "Invalid" ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceMoveStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Denotes whether move operation is in progress - """ + +class ResourceMoveStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Denotes whether move operation is in progress.""" NONE = "None" RESOURCE_MOVE_IN_PROGRESS = "ResourceMoveInProgress" RESOURCE_MOVE_FAILED = "ResourceMoveFailed" -class RoleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Local Edge Management Status - """ + +class RoleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Local Edge Management Status.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RoleTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleTypes.""" IOT = "IOT" ASA = "ASA" @@ -390,24 +378,24 @@ class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CLOUD_EDGE_MANAGEMENT = "CloudEdgeManagement" KUBERNETES = "Kubernetes" -class ShareAccessProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Access protocol to be used by the share. - """ + +class ShareAccessProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access protocol to be used by the share.""" SMB = "SMB" NFS = "NFS" -class ShareAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed on the share for this user. - """ + +class ShareAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed on the share for this user.""" CHANGE = "Change" READ = "Read" CUSTOM = "Custom" -class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the share. - """ + +class ShareStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the share.""" OFFLINE = "Offline" UNKNOWN = "Unknown" @@ -415,22 +403,24 @@ class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class ShipmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class ShipmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ShipmentType.""" NOT_APPLICABLE = "NotApplicable" SHIPPED_TO_CUSTOMER = "ShippedToCustomer" SELF_PICKUP = "SelfPickup" -class SkuAvailability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Links to the next set of results - """ + +class SkuAvailability(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Links to the next set of results.""" AVAILABLE = "Available" UNAVAILABLE = "Unavailable" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku name. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku name.""" GATEWAY = "Gateway" EDGE = "Edge" @@ -454,36 +444,36 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RCA_LARGE = "RCA_Large" RDC = "RDC" -class SkuSignupOption(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Sku can be signed up by customer or not. - """ + +class SkuSignupOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sku can be signed up by customer or not.""" NONE = "None" AVAILABLE = "Available" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku tier. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku tier.""" STANDARD = "Standard" -class SkuVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Availability of the Sku as preview/stable. - """ + +class SkuVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Availability of the Sku as preview/stable.""" STABLE = "Stable" PREVIEW = "Preview" -class SSLStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Signifies whether SSL needs to be enabled or not. - """ + +class SSLStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Signifies whether SSL needs to be enabled or not.""" ENABLED = "Enabled" DISABLED = "Disabled" -class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the storage account - """ + +class StorageAccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the storage account.""" OK = "OK" OFFLINE = "Offline" @@ -491,7 +481,9 @@ class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SubscriptionState.""" REGISTERED = "Registered" WARNED = "Warned" @@ -499,7 +491,9 @@ class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETED = "Deleted" UNREGISTERED = "Unregistered" -class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class TimeGrain(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TimeGrain.""" PT1_M = "PT1M" PT5_M = "PT5M" @@ -510,25 +504,25 @@ class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PT12_H = "PT12H" PT1_D = "PT1D" -class TriggerEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Trigger Kind. - """ + +class TriggerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trigger Kind.""" FILE_EVENT = "FileEvent" PERIODIC_TIMER_EVENT = "PeriodicTimerEvent" -class UpdateOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current update operation. - """ + +class UpdateOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current update operation.""" NONE = "None" SCAN = "Scan" DOWNLOAD = "Download" INSTALL = "Install" -class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current stage of the update operation. - """ + +class UpdateOperationStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current stage of the update operation.""" UNKNOWN = "Unknown" INITIAL = "Initial" @@ -548,9 +542,9 @@ class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESCAN_COMPLETE = "RescanComplete" RESCAN_FAILED = "RescanFailed" -class UserType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of the user. - """ + +class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the user.""" SHARE = "Share" LOCAL_MANAGEMENT = "LocalManagement" diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_models.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_models.py deleted file mode 100644 index 88a49cb1ce06..000000000000 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_models.py +++ /dev/null @@ -1,5119 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class ARMBaseModel(msrest.serialization.Model): - """Represents the base class for all object models. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Addon(ARMBaseModel): - """Role Addon. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ArcAddon, IoTAddon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - _subtype_map = { - 'kind': {'ArcForKubernetes': 'ArcAddon', 'IotEdge': 'IoTAddon'} - } - - def __init__( - self, - **kwargs - ): - super(Addon, self).__init__(**kwargs) - self.kind = 'Addon' # type: str - self.system_data = None - - -class AddonList(msrest.serialization.Model): - """Collection of all the Role addon on the Azure Stack Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Addon] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Address(msrest.serialization.Model): - """The shipping address of the customer. - - All required parameters must be populated in order to send to Azure. - - :param address_line1: The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: The postal code. - :type postal_code: str - :param city: The city name. - :type city: str - :param state: The state name. - :type state: str - :param country: Required. The country name. - :type country: str - """ - - _validation = { - 'country': {'required': True}, - } - - _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Address, self).__init__(**kwargs) - self.address_line1 = kwargs.get('address_line1', None) - self.address_line2 = kwargs.get('address_line2', None) - self.address_line3 = kwargs.get('address_line3', None) - self.postal_code = kwargs.get('postal_code', None) - self.city = kwargs.get('city', None) - self.state = kwargs.get('state', None) - self.country = kwargs['country'] - - -class Alert(ARMBaseModel): - """Alert on the data box edge/gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Alert generated in the resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :ivar title: Alert title. - :vartype title: str - :ivar alert_type: Alert type. - :vartype alert_type: str - :ivar appeared_at_date_time: UTC time when the alert appeared. - :vartype appeared_at_date_time: ~datetime.datetime - :ivar recommendation: Alert recommendation. - :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", - "Critical". - :vartype severity: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AlertSeverity - :ivar error_details: Error details of the alert. - :vartype error_details: ~azure.mgmt.databoxedge.v2020_12_01.models.AlertErrorDetails - :ivar detailed_information: Alert details. - :vartype detailed_information: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) - self.system_data = None - self.title = None - self.alert_type = None - self.appeared_at_date_time = None - self.recommendation = None - self.severity = None - self.error_details = None - self.detailed_information = None - - -class AlertErrorDetails(msrest.serialization.Model): - """Error details for the alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code. - :vartype error_code: str - :ivar error_message: Error Message. - :vartype error_message: str - :ivar occurrences: Number of occurrences. - :vartype occurrences: int - """ - - _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) - self.error_code = None - self.error_message = None - self.occurrences = None - - -class AlertList(msrest.serialization.Model): - """Collection of alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Alert] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ArcAddon(Addon): - """Arc Addon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param subscription_id: Required. Arc resource subscription Id. - :type subscription_id: str - :param resource_group_name: Required. Arc resource group name. - :type resource_group_name: str - :param resource_name: Required. Arc resource Name. - :type resource_name: str - :param resource_location: Required. Arc resource location. - :type resource_location: str - :ivar version: Arc resource version. - :vartype version: str - :ivar host_platform: Host OS supported by the Arc addon. Possible values include: "Windows", - "Linux". - :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'subscription_id': {'required': True}, - 'resource_group_name': {'required': True}, - 'resource_name': {'required': True}, - 'resource_location': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'properties.resourceGroupName', 'type': 'str'}, - 'resource_name': {'key': 'properties.resourceName', 'type': 'str'}, - 'resource_location': {'key': 'properties.resourceLocation', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArcAddon, self).__init__(**kwargs) - self.kind = 'ArcForKubernetes' # type: str - self.subscription_id = kwargs['subscription_id'] - self.resource_group_name = kwargs['resource_group_name'] - self.resource_name = kwargs['resource_name'] - self.resource_location = kwargs['resource_location'] - self.version = None - self.host_platform = None - self.host_platform_type = None - self.provisioning_state = None - - -class AsymmetricEncryptedSecret(msrest.serialization.Model): - """Represent the secrets intended for encryption with asymmetric key pair. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the - value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or - ~azure.mgmt.databoxedge.v2020_12_01.models.EncryptionAlgorithm - """ - - _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) - self.value = kwargs['value'] - self.encryption_cert_thumbprint = kwargs.get('encryption_cert_thumbprint', None) - self.encryption_algorithm = kwargs['encryption_algorithm'] - - -class Authentication(msrest.serialization.Model): - """Authentication mechanism for IoT devices. - - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2020_12_01.models.SymmetricKey - """ - - _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, - } - - def __init__( - self, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) - self.symmetric_key = kwargs.get('symmetric_key', None) - - -class AzureContainerInfo(msrest.serialization.Model): - """Azure container mapping of the endpoint. - - All required parameters must be populated in order to send to Azure. - - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerDataFormat - """ - - _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, - } - - _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) - self.storage_account_credential_id = kwargs['storage_account_credential_id'] - self.container_name = kwargs['container_name'] - self.data_format = kwargs['data_format'] - - -class BandwidthSchedule(ARMBaseModel): - """The bandwidth schedule details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Bandwidth object related to ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2020_12_01.models.DayOfWeek] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) - self.system_data = None - self.start = kwargs['start'] - self.stop = kwargs['stop'] - self.rate_in_mbps = kwargs['rate_in_mbps'] - self.days = kwargs['days'] - - -class BandwidthSchedulesList(msrest.serialization.Model): - """The collection of bandwidth schedules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of bandwidth schedules. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ClientAccessRight(msrest.serialization.Model): - """The mapping between a particular client IP and the type of access client has on the NFS share. - - All required parameters must be populated in order to send to Azure. - - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ClientPermissionType - """ - - _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, - } - - _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) - self.client = kwargs['client'] - self.access_permission = kwargs['access_permission'] - - -class Role(ARMBaseModel): - """Compute role. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - _subtype_map = { - 'kind': {'CloudEdgeManagement': 'CloudEdgeManagementRole', 'IOT': 'IoTRole', 'Kubernetes': 'KubernetesRole', 'MEC': 'MECRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str - self.system_data = None - - -class CloudEdgeManagementRole(Role): - """CloudEdgeManagementRole role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :ivar local_management_status: Local Edge Management Status. Possible values include: - "Enabled", "Disabled". - :vartype local_management_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus - :ivar edge_profile: Edge Profile of the resource. - :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfile - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'local_management_status': {'readonly': True}, - 'edge_profile': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'local_management_status': {'key': 'properties.localManagementStatus', 'type': 'str'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudEdgeManagementRole, self).__init__(**kwargs) - self.kind = 'CloudEdgeManagement' # type: str - self.local_management_status = None - self.edge_profile = None - self.role_status = kwargs.get('role_status', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2020_12_01.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class CniConfig(msrest.serialization.Model): - """Cni configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Cni type. - :vartype type: str - :ivar version: Cni version. - :vartype version: str - :ivar pod_subnet: Pod Subnet. - :vartype pod_subnet: str - :ivar service_subnet: Service subnet. - :vartype service_subnet: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - 'pod_subnet': {'readonly': True}, - 'service_subnet': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'pod_subnet': {'key': 'podSubnet', 'type': 'str'}, - 'service_subnet': {'key': 'serviceSubnet', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CniConfig, self).__init__(**kwargs) - self.type = None - self.version = None - self.pod_subnet = None - self.service_subnet = None - - -class ComputeResource(msrest.serialization.Model): - """Compute infrastructure Resource. - - All required parameters must be populated in order to send to Azure. - - :param processor_count: Required. Processor count. - :type processor_count: int - :param memory_in_gb: Required. Memory in GB. - :type memory_in_gb: long - """ - - _validation = { - 'processor_count': {'required': True}, - 'memory_in_gb': {'required': True}, - } - - _attribute_map = { - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeResource, self).__init__(**kwargs) - self.processor_count = kwargs['processor_count'] - self.memory_in_gb = kwargs['memory_in_gb'] - - -class ContactDetails(msrest.serialization.Model): - """Contains all the contact details of the customer. - - All required parameters must be populated in order to send to Azure. - - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] - """ - - _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) - self.contact_person = kwargs['contact_person'] - self.company_name = kwargs['company_name'] - self.phone = kwargs['phone'] - self.email_list = kwargs['email_list'] - - -class Container(ARMBaseModel): - """Represents a container on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Container in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". - :vartype container_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerDataFormat - :ivar refresh_details: Details of the refresh job on this container. - :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_12_01.models.RefreshDetails - :ivar created_date_time: The UTC time when container got created. - :vartype created_date_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Container, self).__init__(**kwargs) - self.system_data = None - self.container_status = None - self.data_format = kwargs['data_format'] - self.refresh_details = None - self.created_date_time = None - - -class ContainerList(msrest.serialization.Model): - """Collection of all the containers on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of containers. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Container] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevice(ARMBaseModel): - """The Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure - geographical region (for example, West US, East US, or Southeast Asia). The geographical region - of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2020_12_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceIdentity - :ivar kind: The etag for the devices. Possible values include: "AzureDataBoxGateway", - "AzureStackEdge", "AzureStackHub", "AzureModularDataCentre". - :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceKind - :ivar system_data: DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or - ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceStatus - :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. - :vartype serial_number: str - :ivar description: The Description of the Data Box Edge/Gateway device. - :vartype description: str - :ivar model_description: The description of the Data Box Edge/Gateway device model. - :vartype model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". - :vartype device_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DeviceType - :ivar friendly_name: The Data Box Edge/Gateway device name. - :vartype friendly_name: str - :ivar culture: The Data Box Edge/Gateway device culture. - :vartype culture: str - :ivar device_model: The Data Box Edge/Gateway device model. - :vartype device_model: str - :ivar device_software_version: The Data Box Edge/Gateway device software version. - :vartype device_software_version: str - :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long - :ivar time_zone: The Data Box Edge/Gateway device timezone. - :vartype time_zone: str - :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). - :vartype device_hcs_version: str - :ivar configured_role_types: Type of compute roles configured. - :vartype configured_role_types: list[str or - ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes] - :ivar node_count: The number of nodes in the cluster. - :vartype node_count: int - :ivar resource_move_details: The details of the move operation on this resource. - :vartype resource_move_details: ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceMoveDetails - :ivar edge_profile: The details of Edge Profile for this resource. - :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfile - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'system_data': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'description': {'readonly': True}, - 'model_description': {'readonly': True}, - 'device_type': {'readonly': True}, - 'friendly_name': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'edge_profile': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - 'resource_move_details': {'key': 'properties.resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - self.etag = kwargs.get('etag', None) - self.identity = kwargs.get('identity', None) - self.kind = None - self.system_data = None - self.data_box_edge_device_status = kwargs.get('data_box_edge_device_status', None) - self.serial_number = None - self.description = None - self.model_description = None - self.device_type = None - self.friendly_name = None - self.culture = None - self.device_model = None - self.device_software_version = None - self.device_local_capacity = None - self.time_zone = None - self.device_hcs_version = None - self.configured_role_types = None - self.node_count = None - self.resource_move_details = None - self.edge_profile = None - - -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): - """The extended Info of the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to - encrypt any secret. - :type encryption_key: str - :ivar resource_key: The Resource ID of the Resource. - :vartype resource_key: str - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key - Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client - Key Vault. - :type channel_integrity_key_version: str - :param key_vault_sync_status: Key vault sync status. Possible values include: "KeyVaultSynced", - "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", "KeyVaultSyncing". - :type key_vault_sync_status: str or - ~azure.mgmt.databoxedge.v2020_12_01.models.KeyVaultSyncStatus - :ivar device_secrets: Device secrets, will be returned only with ODataFilter - $expand=deviceSecrets. - :vartype device_secrets: ~azure.mgmt.databoxedge.v2020_12_01.models.DeviceSecrets - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - 'device_secrets': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - 'client_secret_store_id': {'key': 'properties.clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'properties.clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'properties.channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'properties.channelIntegrityKeyVersion', 'type': 'str'}, - 'key_vault_sync_status': {'key': 'properties.keyVaultSyncStatus', 'type': 'str'}, - 'device_secrets': {'key': 'properties.deviceSecrets', 'type': 'DeviceSecrets'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) - self.encryption_key_thumbprint = kwargs.get('encryption_key_thumbprint', None) - self.encryption_key = kwargs.get('encryption_key', None) - self.resource_key = None - self.client_secret_store_id = kwargs.get('client_secret_store_id', None) - self.client_secret_store_url = kwargs.get('client_secret_store_url', None) - self.channel_integrity_key_name = kwargs.get('channel_integrity_key_name', None) - self.channel_integrity_key_version = kwargs.get('channel_integrity_key_version', None) - self.key_vault_sync_status = kwargs.get('key_vault_sync_status', None) - self.device_secrets = None - - -class DataBoxEdgeDeviceExtendedInfoPatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device extended info patch. - - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key - Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client - Key Vault. - :type channel_integrity_key_version: str - :param sync_status: For changing or to initiate the resync to key-vault set the status to - KeyVaultSyncPending, rest of the status will not be applicable. Possible values include: - "KeyVaultSynced", "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", - "KeyVaultSyncing". - :type sync_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.KeyVaultSyncStatus - """ - - _attribute_map = { - 'client_secret_store_id': {'key': 'clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'channelIntegrityKeyVersion', 'type': 'str'}, - 'sync_status': {'key': 'syncStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfoPatch, self).__init__(**kwargs) - self.client_secret_store_id = kwargs.get('client_secret_store_id', None) - self.client_secret_store_url = kwargs.get('client_secret_store_url', None) - self.channel_integrity_key_name = kwargs.get('channel_integrity_key_name', None) - self.channel_integrity_key_version = kwargs.get('channel_integrity_key_version', None) - self.sync_status = kwargs.get('sync_status', None) - - -class DataBoxEdgeDeviceList(msrest.serialization.Model): - """The collection of Data Box Edge/Gateway devices. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Data Box Edge/Gateway devices. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevicePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device patch. - - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceIdentity - :param edge_profile: Edge Profile property of the Data Box Edge/Gateway device. - :type edge_profile: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfilePatch - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfilePatch'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.identity = kwargs.get('identity', None) - self.edge_profile = kwargs.get('edge_profile', None) - - -class DataBoxEdgeMoveRequest(msrest.serialization.Model): - """Resource Move details. - - All required parameters must be populated in order to send to Azure. - - :param target_resource_group: Required. Target resource group ARMId. - :type target_resource_group: str - :param resources: Required. List of resources to be moved. - :type resources: list[str] - """ - - _validation = { - 'target_resource_group': {'required': True}, - 'resources': {'required': True}, - } - - _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeMoveRequest, self).__init__(**kwargs) - self.target_resource_group = kwargs['target_resource_group'] - self.resources = kwargs['resources'] - - -class DataBoxEdgeSku(msrest.serialization.Model): - """The Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". - :vartype name: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuName - :ivar kind: The Sku kind. - :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". - :vartype tier: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuTier - :ivar size: The Sku kind. - :vartype size: str - :ivar family: The Sku family. - :vartype family: str - :ivar locations: Availability of the Sku for the region. - :vartype locations: list[str] - :ivar api_versions: The API versions in which Sku is available. - :vartype api_versions: list[str] - :ivar location_info: Availability of the Sku for the location/zone/site. - :vartype location_info: list[~azure.mgmt.databoxedge.v2020_12_01.models.SkuLocationInfo] - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2020_12_01.models.SkuCost] - :ivar signup_option: Sku can be signed up by customer or not. Possible values include: "None", - "Available". - :vartype signup_option: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuSignupOption - :ivar version: Availability of the Sku as preview/stable. Possible values include: "Stable", - "Preview". - :vartype version: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuVersion - :ivar availability: Links to the next set of results. Possible values include: "Available", - "Unavailable". - :vartype availability: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuAvailability - :ivar shipment_types: List of Shipment Types supported by this SKU. - :vartype shipment_types: list[str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShipmentType] - :ivar capabilities: The capability info of the SKU. - :vartype capabilities: list[~azure.mgmt.databoxedge.v2020_12_01.models.SkuCapability] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - 'shipment_types': {'readonly': True}, - 'capabilities': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, - 'shipment_types': {'key': 'shipmentTypes', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SkuCapability]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) - self.resource_type = None - self.name = None - self.kind = None - self.tier = None - self.size = None - self.family = None - self.locations = None - self.api_versions = None - self.location_info = None - self.costs = None - self.signup_option = None - self.version = None - self.availability = None - self.shipment_types = None - self.capabilities = None - - -class DataBoxEdgeSkuList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceType Sku. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DCAccessCode(msrest.serialization.Model): - """DC Access code in the case of Self Managed Shipping. - - :param auth_code: DCAccess Code for the Self Managed shipment. - :type auth_code: str - """ - - _attribute_map = { - 'auth_code': {'key': 'properties.authCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DCAccessCode, self).__init__(**kwargs) - self.auth_code = kwargs.get('auth_code', None) - - -class DeviceSecrets(msrest.serialization.Model): - """Device Secrets. - - :param hcs_data_volume_bit_locker_external_key: Keyvault Id of - HcsDataVolumeBitLockerExternalKey. - :type hcs_data_volume_bit_locker_external_key: - ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param hcs_internal_volume_bit_locker_external_key: Keyvault Id of - HcsInternalVolumeBitLockerExternalKey. - :type hcs_internal_volume_bit_locker_external_key: - ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param system_volume_bit_locker_recovery_key: Keyvault Id of SystemVolumeBitLockerRecoveryKey. - :type system_volume_bit_locker_recovery_key: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param sed_encryption_external_key_id: Keyvault Id of SEDEncryptionExternalKeyId. - :type sed_encryption_external_key_id: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param sed_encryption_external_key: Keyvault Id of SEDEncryptionExternalKey. - :type sed_encryption_external_key: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param bmc_default_user_password: Keyvault Id of BMCDefaultUserPassword. - :type bmc_default_user_password: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param rotate_key_for_data_volume_bitlocker: Keyvault Id of RotateKeyForDataVolumeBitlocker. - :type rotate_key_for_data_volume_bitlocker: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param rotate_keys_for_sed_drives_serialized: Keyvault Id of RotateKeysForSedDrivesSerialized. - :type rotate_keys_for_sed_drives_serialized: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - """ - - _attribute_map = { - 'hcs_data_volume_bit_locker_external_key': {'key': 'hcsDataVolumeBitLockerExternalKey', 'type': 'Secret'}, - 'hcs_internal_volume_bit_locker_external_key': {'key': 'hcsInternalVolumeBitLockerExternalKey', 'type': 'Secret'}, - 'system_volume_bit_locker_recovery_key': {'key': 'systemVolumeBitLockerRecoveryKey', 'type': 'Secret'}, - 'sed_encryption_external_key_id': {'key': 'sedEncryptionExternalKeyId', 'type': 'Secret'}, - 'sed_encryption_external_key': {'key': 'sedEncryptionExternalKey', 'type': 'Secret'}, - 'bmc_default_user_password': {'key': 'bmcDefaultUserPassword', 'type': 'Secret'}, - 'rotate_key_for_data_volume_bitlocker': {'key': 'rotateKeyForDataVolumeBitlocker', 'type': 'Secret'}, - 'rotate_keys_for_sed_drives_serialized': {'key': 'rotateKeysForSedDrivesSerialized', 'type': 'Secret'}, - } - - def __init__( - self, - **kwargs - ): - super(DeviceSecrets, self).__init__(**kwargs) - self.hcs_data_volume_bit_locker_external_key = kwargs.get('hcs_data_volume_bit_locker_external_key', None) - self.hcs_internal_volume_bit_locker_external_key = kwargs.get('hcs_internal_volume_bit_locker_external_key', None) - self.system_volume_bit_locker_recovery_key = kwargs.get('system_volume_bit_locker_recovery_key', None) - self.sed_encryption_external_key_id = kwargs.get('sed_encryption_external_key_id', None) - self.sed_encryption_external_key = kwargs.get('sed_encryption_external_key', None) - self.bmc_default_user_password = kwargs.get('bmc_default_user_password', None) - self.rotate_key_for_data_volume_bitlocker = kwargs.get('rotate_key_for_data_volume_bitlocker', None) - self.rotate_keys_for_sed_drives_serialized = kwargs.get('rotate_keys_for_sed_drives_serialized', None) - - -class EdgeProfile(msrest.serialization.Model): - """Details about Edge Profile for the resource. - - :param subscription: Edge Profile Subscription. - :type subscription: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfileSubscription - """ - - _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscription'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfile, self).__init__(**kwargs) - self.subscription = kwargs.get('subscription', None) - - -class EdgeProfilePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway Edge Profile patch. - - :param subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. - :type subscription: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfileSubscriptionPatch - """ - - _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscriptionPatch'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfilePatch, self).__init__(**kwargs) - self.subscription = kwargs.get('subscription', None) - - -class EdgeProfileSubscription(msrest.serialization.Model): - """Subscription details for the Edge Profile. - - :param registration_id: Edge Subscription Registration ID. - :type registration_id: str - :param id: ARM ID of the subscription. - :type id: str - :param state: Possible values include: "Registered", "Warned", "Suspended", "Deleted", - "Unregistered". - :type state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SubscriptionState - :param registration_date: - :type registration_date: str - :param subscription_id: - :type subscription_id: str - :param tenant_id: - :type tenant_id: str - :param location_placement_id: - :type location_placement_id: str - :param quota_id: - :type quota_id: str - :param serialized_details: - :type serialized_details: str - :param registered_features: - :type registered_features: - list[~azure.mgmt.databoxedge.v2020_12_01.models.SubscriptionRegisteredFeatures] - """ - - _attribute_map = { - 'registration_id': {'key': 'registrationId', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'registration_date': {'key': 'registrationDate', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'location_placement_id': {'key': 'properties.locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'properties.quotaId', 'type': 'str'}, - 'serialized_details': {'key': 'properties.serializedDetails', 'type': 'str'}, - 'registered_features': {'key': 'properties.registeredFeatures', 'type': '[SubscriptionRegisteredFeatures]'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfileSubscription, self).__init__(**kwargs) - self.registration_id = kwargs.get('registration_id', None) - self.id = kwargs.get('id', None) - self.state = kwargs.get('state', None) - self.registration_date = kwargs.get('registration_date', None) - self.subscription_id = kwargs.get('subscription_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.location_placement_id = kwargs.get('location_placement_id', None) - self.quota_id = kwargs.get('quota_id', None) - self.serialized_details = kwargs.get('serialized_details', None) - self.registered_features = kwargs.get('registered_features', None) - - -class EdgeProfileSubscriptionPatch(msrest.serialization.Model): - """The Data Box Edge/Gateway Edge Profile Subscription patch. - - :param id: The path ID that uniquely identifies the subscription of the edge profile. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfileSubscriptionPatch, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class EtcdInfo(msrest.serialization.Model): - """Etcd configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Etcd type. - :vartype type: str - :ivar version: Etcd version. - :vartype version: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EtcdInfo, self).__init__(**kwargs) - self.type = None - self.version = None - - -class Trigger(ARMBaseModel): - """Trigger details. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.TriggerEventType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } - - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.system_data = None - self.kind = 'Trigger' # type: str - - -class FileEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2020_12_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2020_12_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class FileSourceInfo(msrest.serialization.Model): - """File source details. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. File share ID. - :type share_id: str - """ - - _validation = { - 'share_id': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - - -class GenerateCertResponse(msrest.serialization.Model): - """Used in activation key generation flow. - - :param public_key: Gets or sets base64 encoded certificate raw data, - this is the public part needed to be uploaded to cert vault. - :type public_key: str - :param private_key: Gets or sets base64 encoded private part of the certificate, - needed to form the activation key. - :type private_key: str - :param expiry_time_in_utc: Gets or sets expiry time in UTC. - :type expiry_time_in_utc: str - """ - - _attribute_map = { - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'expiry_time_in_utc': {'key': 'expiryTimeInUTC', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GenerateCertResponse, self).__init__(**kwargs) - self.public_key = kwargs.get('public_key', None) - self.private_key = kwargs.get('private_key', None) - self.expiry_time_in_utc = kwargs.get('expiry_time_in_utc', None) - - -class ImageRepositoryCredential(msrest.serialization.Model): - """Image repository credential. - - All required parameters must be populated in order to send to Azure. - - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, - } - - _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageRepositoryCredential, self).__init__(**kwargs) - self.image_repository_url = kwargs['image_repository_url'] - self.user_name = kwargs['user_name'] - self.password = kwargs.get('password', None) - - -class IoTAddon(Addon): - """IoT Addon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param io_t_device_details: Required. IoT device metadata to which appliance needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo - :param io_t_edge_device_details: Required. IoT edge device to which the IoT Addon needs to be - configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo - :ivar version: Version of IoT running on the appliance. - :vartype version: str - :ivar host_platform: Host OS supported by the IoT addon. Possible values include: "Windows", - "Linux". - :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'io_t_device_details': {'required': True}, - 'io_t_edge_device_details': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTAddon, self).__init__(**kwargs) - self.kind = 'IotEdge' # type: str - self.io_t_device_details = kwargs['io_t_device_details'] - self.io_t_edge_device_details = kwargs['io_t_edge_device_details'] - self.version = None - self.host_platform = None - self.host_platform_type = None - self.provisioning_state = None - - -class IoTDeviceInfo(msrest.serialization.Model): - """Metadata of IoT device/IoT Edge device to be configured. - - All required parameters must be populated in order to send to Azure. - - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2020_12_01.models.Authentication - """ - - _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) - self.device_id = kwargs['device_id'] - self.io_t_host_hub = kwargs['io_t_host_hub'] - self.io_t_host_hub_id = kwargs.get('io_t_host_hub_id', None) - self.authentication = kwargs.get('authentication', None) - - -class IoTEdgeAgentInfo(msrest.serialization.Model): - """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. - - All required parameters must be populated in order to send to Azure. - - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: ~azure.mgmt.databoxedge.v2020_12_01.models.ImageRepositoryCredential - """ - - _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, - } - - _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) - self.image_name = kwargs['image_name'] - self.tag = kwargs['tag'] - self.image_repository = kwargs.get('image_repository', None) - - -class IoTRole(Role): - """Compute role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", - "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot - runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.HostPlatformType - :param compute_resource: Resource allocation. - :type compute_resource: ~azure.mgmt.databoxedge.v2020_12_01.models.ComputeResource - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'compute_resource': {'key': 'properties.computeResource', 'type': 'ComputeResource'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.io_t_device_details = kwargs.get('io_t_device_details', None) - self.io_t_edge_device_details = kwargs.get('io_t_edge_device_details', None) - self.share_mappings = kwargs.get('share_mappings', None) - self.io_t_edge_agent_info = kwargs.get('io_t_edge_agent_info', None) - self.host_platform_type = None - self.compute_resource = kwargs.get('compute_resource', None) - self.role_status = kwargs.get('role_status', None) - - -class Ipv4Config(msrest.serialization.Model): - """Details related to the IPv4 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv4 address of the network adapter. - :vartype ip_address: str - :ivar subnet: The IPv4 subnet of the network adapter. - :vartype subnet: str - :ivar gateway: The IPv4 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) - self.ip_address = None - self.subnet = None - self.gateway = None - - -class Ipv6Config(msrest.serialization.Model): - """Details related to the IPv6 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv6 address of the network adapter. - :vartype ip_address: str - :ivar prefix_length: The IPv6 prefix of the network adapter. - :vartype prefix_length: int - :ivar gateway: The IPv6 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) - self.ip_address = None - self.prefix_length = None - self.gateway = None - - -class Job(msrest.serialization.Model): - """A device job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The name of the object. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.JobStatus - :ivar start_time: The UTC date and time at which the job started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The UTC date and time at which the job completed. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: The percentage of the job that is complete. - :vartype percent_complete: int - :ivar error: The error details. - :vartype error: ~azure.mgmt.databoxedge.v2020_12_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer", "Backup", "Restore", - "TriggerSupportPackage". - :vartype job_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", - "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", - "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". - :vartype current_stage: str or ~azure.mgmt.databoxedge.v2020_12_01.models.UpdateOperationStage - :ivar download_progress: The download progress. - :vartype download_progress: ~azure.mgmt.databoxedge.v2020_12_01.models.UpdateDownloadProgress - :ivar install_progress: The install progress. - :vartype install_progress: ~azure.mgmt.databoxedge.v2020_12_01.models.UpdateInstallProgress - :ivar total_refresh_errors: Total number of errors encountered during the refresh process. - :vartype total_refresh_errors: int - :ivar error_manifest_file: Local share/remote container relative path to the error manifest - file of the refresh. - :vartype error_manifest_file: str - :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. - :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_time = None - self.end_time = None - self.percent_complete = None - self.error = None - self.job_type = None - self.current_stage = None - self.download_progress = None - self.install_progress = None - self.total_refresh_errors = None - self.error_manifest_file = None - self.refreshed_entity_id = None - self.folder = kwargs.get('folder', None) - - -class JobErrorDetails(msrest.serialization.Model): - """The job error information containing the list of job errors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_details: The error details. - :vartype error_details: list[~azure.mgmt.databoxedge.v2020_12_01.models.JobErrorItem] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) - self.error_details = None - self.code = None - self.message = None - - -class JobErrorItem(msrest.serialization.Model): - """The job error items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendations: The recommended actions. - :vartype recommendations: list[str] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) - self.recommendations = None - self.code = None - self.message = None - - -class KubernetesClusterInfo(msrest.serialization.Model): - """Kubernetes cluster configuration. - - 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 etcd_info: Etcd configuration. - :vartype etcd_info: ~azure.mgmt.databoxedge.v2020_12_01.models.EtcdInfo - :ivar nodes: Kubernetes cluster nodes. - :vartype nodes: list[~azure.mgmt.databoxedge.v2020_12_01.models.NodeInfo] - :param version: Required. Kubernetes cluster version. - :type version: str - """ - - _validation = { - 'etcd_info': {'readonly': True}, - 'nodes': {'readonly': True}, - 'version': {'required': True}, - } - - _attribute_map = { - 'etcd_info': {'key': 'etcdInfo', 'type': 'EtcdInfo'}, - 'nodes': {'key': 'nodes', 'type': '[NodeInfo]'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesClusterInfo, self).__init__(**kwargs) - self.etcd_info = None - self.nodes = None - self.version = kwargs['version'] - - -class KubernetesIPConfiguration(msrest.serialization.Model): - """Kubernetes node IP configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar port: Port of the Kubernetes node. - :vartype port: str - :param ip_address: IP address of the Kubernetes node. - :type ip_address: str - """ - - _validation = { - 'port': {'readonly': True}, - } - - _attribute_map = { - 'port': {'key': 'port', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesIPConfiguration, self).__init__(**kwargs) - self.port = None - self.ip_address = kwargs.get('ip_address', None) - - -class KubernetesRole(Role): - """Kubernetes role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param host_platform: Host OS supported by the Kubernetes role. Possible values include: - "Windows", "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType - :ivar provisioning_state: State of Kubernetes deployment. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesState - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.HostPlatformType - :param kubernetes_cluster_info: Kubernetes cluster configuration. - :type kubernetes_cluster_info: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesClusterInfo - :param kubernetes_role_resources: Kubernetes role resources. - :type kubernetes_role_resources: - ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleResources - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'kubernetes_cluster_info': {'key': 'properties.kubernetesClusterInfo', 'type': 'KubernetesClusterInfo'}, - 'kubernetes_role_resources': {'key': 'properties.kubernetesRoleResources', 'type': 'KubernetesRoleResources'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRole, self).__init__(**kwargs) - self.kind = 'Kubernetes' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.provisioning_state = None - self.host_platform_type = None - self.kubernetes_cluster_info = kwargs.get('kubernetes_cluster_info', None) - self.kubernetes_role_resources = kwargs.get('kubernetes_role_resources', None) - self.role_status = kwargs.get('role_status', None) - - -class KubernetesRoleCompute(msrest.serialization.Model): - """Kubernetes role compute resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param vm_profile: Required. VM profile. - :type vm_profile: str - :ivar memory_in_bytes: Memory in bytes. - :vartype memory_in_bytes: long - :ivar processor_count: Processor count. - :vartype processor_count: int - """ - - _validation = { - 'vm_profile': {'required': True}, - 'memory_in_bytes': {'readonly': True}, - 'processor_count': {'readonly': True}, - } - - _attribute_map = { - 'vm_profile': {'key': 'vmProfile', 'type': 'str'}, - 'memory_in_bytes': {'key': 'memoryInBytes', 'type': 'long'}, - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleCompute, self).__init__(**kwargs) - self.vm_profile = kwargs['vm_profile'] - self.memory_in_bytes = None - self.processor_count = None - - -class KubernetesRoleNetwork(msrest.serialization.Model): - """Kubernetes role network resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar cni_config: Cni configuration. - :vartype cni_config: ~azure.mgmt.databoxedge.v2020_12_01.models.CniConfig - :ivar load_balancer_config: Load balancer configuration. - :vartype load_balancer_config: ~azure.mgmt.databoxedge.v2020_12_01.models.LoadBalancerConfig - """ - - _validation = { - 'cni_config': {'readonly': True}, - 'load_balancer_config': {'readonly': True}, - } - - _attribute_map = { - 'cni_config': {'key': 'cniConfig', 'type': 'CniConfig'}, - 'load_balancer_config': {'key': 'loadBalancerConfig', 'type': 'LoadBalancerConfig'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleNetwork, self).__init__(**kwargs) - self.cni_config = None - self.load_balancer_config = None - - -class KubernetesRoleResources(msrest.serialization.Model): - """Kubernetes role resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param storage: Kubernetes role storage resource. - :type storage: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleStorage - :param compute: Required. Kubernetes role compute resource. - :type compute: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleCompute - :ivar network: Kubernetes role network resource. - :vartype network: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleNetwork - """ - - _validation = { - 'compute': {'required': True}, - 'network': {'readonly': True}, - } - - _attribute_map = { - 'storage': {'key': 'storage', 'type': 'KubernetesRoleStorage'}, - 'compute': {'key': 'compute', 'type': 'KubernetesRoleCompute'}, - 'network': {'key': 'network', 'type': 'KubernetesRoleNetwork'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleResources, self).__init__(**kwargs) - self.storage = kwargs.get('storage', None) - self.compute = kwargs['compute'] - self.network = None - - -class KubernetesRoleStorage(msrest.serialization.Model): - """Kubernetes role storage resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar storage_classes: Kubernetes storage class info. - :vartype storage_classes: - list[~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleStorageClassInfo] - :param endpoints: Mount points of shares in role(s). - :type endpoints: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] - """ - - _validation = { - 'storage_classes': {'readonly': True}, - } - - _attribute_map = { - 'storage_classes': {'key': 'storageClasses', 'type': '[KubernetesRoleStorageClassInfo]'}, - 'endpoints': {'key': 'endpoints', 'type': '[MountPointMap]'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorage, self).__init__(**kwargs) - self.storage_classes = None - self.endpoints = kwargs.get('endpoints', None) - - -class KubernetesRoleStorageClassInfo(msrest.serialization.Model): - """Kubernetes storage class info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Storage class name. - :vartype name: str - :ivar type: Storage class type. - :vartype type: str - :ivar posix_compliant: If provisioned storage is posix compliant. Possible values include: - "Invalid", "Enabled", "Disabled". - :vartype posix_compliant: str or - ~azure.mgmt.databoxedge.v2020_12_01.models.PosixComplianceStatus - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'posix_compliant': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'posix_compliant': {'key': 'posixCompliant', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorageClassInfo, self).__init__(**kwargs) - self.name = None - self.type = None - self.posix_compliant = None - - -class LoadBalancerConfig(msrest.serialization.Model): - """Load balancer configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Load balancer type. - :vartype type: str - :ivar version: Load balancer version. - :vartype version: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LoadBalancerConfig, self).__init__(**kwargs) - self.type = None - self.version = None - - -class MECRole(Role): - """MEC role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param connection_string: Activation key of the MEC. - :type connection_string: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'AsymmetricEncryptedSecret'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MECRole, self).__init__(**kwargs) - self.kind = 'MEC' # type: str - self.connection_string = kwargs.get('connection_string', None) - self.role_status = kwargs.get('role_status', None) - - -class MetricConfiguration(msrest.serialization.Model): - """Metric configuration. - - All required parameters must be populated in order to send to Azure. - - :param resource_id: Required. The Resource ID on which the metrics should be pushed. - :type resource_id: str - :param mdm_account: The MDM account to which the counters should be pushed. - :type mdm_account: str - :param metric_name_space: The MDM namespace to which the counters should be pushed. This is - required if MDMAccount is specified. - :type metric_name_space: str - :param counter_sets: Required. Host name for the IoT hub associated to the device. - :type counter_sets: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricCounterSet] - """ - - _validation = { - 'resource_id': {'required': True}, - 'counter_sets': {'required': True}, - } - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'mdm_account': {'key': 'mdmAccount', 'type': 'str'}, - 'metric_name_space': {'key': 'metricNameSpace', 'type': 'str'}, - 'counter_sets': {'key': 'counterSets', 'type': '[MetricCounterSet]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricConfiguration, self).__init__(**kwargs) - self.resource_id = kwargs['resource_id'] - self.mdm_account = kwargs.get('mdm_account', None) - self.metric_name_space = kwargs.get('metric_name_space', None) - self.counter_sets = kwargs['counter_sets'] - - -class MetricCounter(msrest.serialization.Model): - """The metric counter. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The counter name. - :type name: str - :param instance: The instance from which counter should be collected. - :type instance: str - :param dimension_filter: The dimension filter. - :type dimension_filter: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimension] - :param additional_dimensions: The additional dimensions to be added to metric. - :type additional_dimensions: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimension] - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, - 'dimension_filter': {'key': 'dimensionFilter', 'type': '[MetricDimension]'}, - 'additional_dimensions': {'key': 'additionalDimensions', 'type': '[MetricDimension]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCounter, self).__init__(**kwargs) - self.name = kwargs['name'] - self.instance = kwargs.get('instance', None) - self.dimension_filter = kwargs.get('dimension_filter', None) - self.additional_dimensions = kwargs.get('additional_dimensions', None) - - -class MetricCounterSet(msrest.serialization.Model): - """The metric counter set. - - All required parameters must be populated in order to send to Azure. - - :param counters: Required. The counters that should be collected in this set. - :type counters: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricCounter] - """ - - _validation = { - 'counters': {'required': True}, - } - - _attribute_map = { - 'counters': {'key': 'counters', 'type': '[MetricCounter]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCounterSet, self).__init__(**kwargs) - self.counters = kwargs['counters'] - - -class MetricDimension(msrest.serialization.Model): - """The metric dimension. - - All required parameters must be populated in order to send to Azure. - - :param source_type: Required. The dimension type. - :type source_type: str - :param source_name: Required. The dimension value. - :type source_name: str - """ - - _validation = { - 'source_type': {'required': True}, - 'source_name': {'required': True}, - } - - _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'source_name': {'key': 'sourceName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) - self.source_type = kwargs['source_type'] - self.source_name = kwargs['source_name'] - - -class MetricDimensionV1(msrest.serialization.Model): - """Metric Dimension v1. - - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimensionV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecificationV1(msrest.serialization.Model): - """Metric specification version 1. - - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or - ~azure.mgmt.databoxedge.v2020_12_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or - ~azure.mgmt.databoxedge.v2020_12_01.models.MetricAggregationType] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.dimensions = kwargs.get('dimensions', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - - -class MonitoringMetricConfiguration(ARMBaseModel): - """The metric setting details for the role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param metric_configurations: Required. The metrics configuration details. - :type metric_configurations: - list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricConfiguration] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'metric_configurations': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metric_configurations': {'key': 'properties.metricConfigurations', 'type': '[MetricConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfiguration, self).__init__(**kwargs) - self.metric_configurations = kwargs['metric_configurations'] - - -class MonitoringMetricConfigurationList(msrest.serialization.Model): - """Collection of metric configurations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of metric configurations. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MonitoringMetricConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfigurationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class MountPointMap(msrest.serialization.Model): - """The share mount point. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str - :ivar role_id: ID of the role to which share is mounted. - :vartype role_id: str - :ivar mount_point: Mount point for the share. - :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". - :vartype mount_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive", - "MEC", "CloudEdgeManagement", "Kubernetes". - :vartype role_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes - """ - - _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.role_id = None - self.mount_point = None - self.mount_type = None - self.role_type = None - - -class NetworkAdapter(msrest.serialization.Model): - """Represents the networkAdapter on a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar adapter_id: Instance ID of network adapter. - :vartype adapter_id: str - :ivar adapter_position: Hardware position of network adapter. - :vartype adapter_position: ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterPosition - :ivar index: Logical index of the adapter. - :vartype index: int - :ivar node_id: Node ID of the network adapter. - :vartype node_id: str - :ivar network_adapter_name: Network adapter name. - :vartype network_adapter_name: str - :ivar label: Hardware label for the adapter. - :vartype label: str - :ivar mac_address: MAC address. - :vartype mac_address: str - :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". - :vartype status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterDHCPStatus - :ivar ipv4_configuration: The IPv4 configuration of the network adapter. - :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2020_12_01.models.Ipv4Config - :ivar ipv6_configuration: The IPv6 configuration of the network adapter. - :vartype ipv6_configuration: ~azure.mgmt.databoxedge.v2020_12_01.models.Ipv6Config - :ivar ipv6_link_local_address: The IPv6 local address. - :vartype ipv6_link_local_address: str - :ivar dns_servers: The list of DNS Servers of the device. - :vartype dns_servers: list[str] - """ - - _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) - self.adapter_id = None - self.adapter_position = None - self.index = None - self.node_id = None - self.network_adapter_name = None - self.label = None - self.mac_address = None - self.link_speed = None - self.status = None - self.rdma_status = kwargs.get('rdma_status', None) - self.dhcp_status = kwargs.get('dhcp_status', None) - self.ipv4_configuration = None - self.ipv6_configuration = None - self.ipv6_link_local_address = None - self.dns_servers = None - - -class NetworkAdapterPosition(msrest.serialization.Model): - """The network adapter position. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". - :vartype network_group: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkGroup - :ivar port: The port. - :vartype port: int - """ - - _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, - } - - _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) - self.network_group = None - self.port = None - - -class NetworkSettings(ARMBaseModel): - """The network settings of a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar network_adapters: The network adapter list on the device. - :vartype network_adapters: list[~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapter] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) - self.network_adapters = None - - -class Node(ARMBaseModel): - """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) - self.node_status = None - self.node_chassis_serial_number = None - self.node_serial_number = None - self.node_display_name = None - self.node_friendly_software_version = None - self.node_hcs_version = None - self.node_instance_id = None - - -class NodeInfo(msrest.serialization.Model): - """Kubernetes node info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Node name. - :vartype name: str - :ivar type: Node type - Master/Worker. Possible values include: "Invalid", "Master", "Worker". - :vartype type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesNodeType - :param ip_configuration: IP Configuration of the Kubernetes node. - :type ip_configuration: - list[~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesIPConfiguration] - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_configuration': {'key': 'ipConfiguration', 'type': '[KubernetesIPConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeInfo, self).__init__(**kwargs) - self.name = None - self.type = None - self.ip_configuration = kwargs.get('ip_configuration', None) - - -class NodeList(msrest.serialization.Model): - """Collection of Nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Nodes. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Node] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class Operation(msrest.serialization.Model): - """Operations. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Is data action. - :type is_data_action: bool - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2020_12_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2020_12_01.models.ServiceSpecification - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationDisplay(msrest.serialization.Model): - """Operation display properties. - - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str - """ - - _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 = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """The list of operations used for the discovery of available provider operations. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class Order(ARMBaseModel): - """The order details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2020_12_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2020_12_01.models.Address - :ivar current_status: Current status of the order. - :vartype current_status: ~azure.mgmt.databoxedge.v2020_12_01.models.OrderStatus - :ivar order_history: List of status changes in the order. - :vartype order_history: list[~azure.mgmt.databoxedge.v2020_12_01.models.OrderStatus] - :ivar serial_number: Serial number of the device. - :vartype serial_number: str - :ivar delivery_tracking_info: Tracking information for the package delivered to the customer - whether it has an original or a replacement device. - :vartype delivery_tracking_info: list[~azure.mgmt.databoxedge.v2020_12_01.models.TrackingInfo] - :ivar return_tracking_info: Tracking information for the package returned from the customer - whether it has an original or a replacement device. - :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2020_12_01.models.TrackingInfo] - :param shipment_type: ShipmentType of the order. Possible values include: "NotApplicable", - "ShippedToCustomer", "SelfPickup". - :type shipment_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShipmentType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'current_status': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - 'shipment_type': {'key': 'properties.shipmentType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Order, self).__init__(**kwargs) - self.contact_information = kwargs.get('contact_information', None) - self.shipping_address = kwargs.get('shipping_address', None) - self.current_status = None - self.order_history = None - self.serial_number = None - self.delivery_tracking_info = None - self.return_tracking_info = None - self.shipment_type = kwargs.get('shipment_type', None) - - -class OrderList(msrest.serialization.Model): - """List of order entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of orders. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Order] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OrderStatus(msrest.serialization.Model): - """Represents a single status change. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", - "AwaitingPickup", "PickupCompleted", "AwaitingDrop". - :type status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.OrderState - :ivar update_date_time: Time of status update. - :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str - :ivar tracking_information: Tracking information related to the state in the ordering flow. - :vartype tracking_information: ~azure.mgmt.databoxedge.v2020_12_01.models.TrackingInfo - :ivar additional_order_details: Dictionary to hold generic information which is not stored - by the already existing properties. - :vartype additional_order_details: dict[str, str] - """ - - _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'tracking_information': {'readonly': True}, - 'additional_order_details': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'tracking_information': {'key': 'trackingInformation', 'type': 'TrackingInfo'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) - self.status = kwargs['status'] - self.update_date_time = None - self.comments = kwargs.get('comments', None) - self.tracking_information = None - self.additional_order_details = None - - -class PeriodicTimerEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2020_12_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2020_12_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class PeriodicTimerSourceInfo(msrest.serialization.Model): - """Periodic timer event source. - - All required parameters must be populated in order to send to Azure. - - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str - """ - - _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) - self.start_time = kwargs['start_time'] - self.schedule = kwargs['schedule'] - self.topic = kwargs.get('topic', None) - - -class RefreshDetails(msrest.serialization.Model): - """Fields for tracking refresh job on the share or container. - - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or - container, this field indicates the ARM resource ID of that job. The field is empty if no job - is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh - job on this particular share or container, if any. This could be a failed job or a successful - job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or - container,if any. This could be a failed job or a successful job. - :type last_job: str - """ - - _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RefreshDetails, self).__init__(**kwargs) - self.in_progress_refresh_job_id = kwargs.get('in_progress_refresh_job_id', None) - self.last_completed_refresh_job_time_in_utc = kwargs.get('last_completed_refresh_job_time_in_utc', None) - self.error_manifest_file = kwargs.get('error_manifest_file', None) - self.last_job = kwargs.get('last_job', None) - - -class ResourceIdentity(msrest.serialization.Model): - """Msi identity details of the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param type: Identity type. Possible values include: "None", "SystemAssigned", "UserAssigned". - :type type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MsiIdentityType - :ivar principal_id: Service Principal Id backing the Msi. - :vartype principal_id: str - :ivar tenant_id: Home Tenant Id. - :vartype tenant_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.principal_id = None - self.tenant_id = None - - -class ResourceMoveDetails(msrest.serialization.Model): - """Fields for tracking resource move. - - :param operation_in_progress: Denotes whether move operation is in progress. Possible values - include: "None", "ResourceMoveInProgress", "ResourceMoveFailed". - :type operation_in_progress: str or - ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceMoveStatus - :param operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to - finish. - :type operation_in_progress_lock_timeout_in_utc: ~datetime.datetime - """ - - _attribute_map = { - 'operation_in_progress': {'key': 'operationInProgress', 'type': 'str'}, - 'operation_in_progress_lock_timeout_in_utc': {'key': 'operationInProgressLockTimeoutInUTC', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceMoveDetails, self).__init__(**kwargs) - self.operation_in_progress = kwargs.get('operation_in_progress', None) - self.operation_in_progress_lock_timeout_in_utc = kwargs.get('operation_in_progress_lock_timeout_in_utc', None) - - -class ResourceTypeSku(msrest.serialization.Model): - """Resource type Sku object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The resource type. - :vartype resource_type: str - :ivar skus: The skus. - :vartype skus: list[~azure.mgmt.databoxedge.v2020_12_01.models.SkuInformation] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'skus': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'skus': {'key': 'skus', 'type': '[SkuInformation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) - self.resource_type = None - self.skus = None - - -class RoleList(msrest.serialization.Model): - """Collection of all the roles on the Data Box Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Role] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RoleSinkInfo(msrest.serialization.Model): - """Compute role against which events will be raised. - - All required parameters must be populated in order to send to Azure. - - :param role_id: Required. Compute role ID. - :type role_id: str - """ - - _validation = { - 'role_id': {'required': True}, - } - - _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) - self.role_id = kwargs['role_id'] - - -class Secret(msrest.serialization.Model): - """Holds device secret either as a KeyVault reference or as an encrypted value. - - :param encrypted_secret: Encrypted (using device public key) secret value. - :type encrypted_secret: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - :param key_vault_id: Id of the Key-Vault where secret is stored (ex: - secrets/AuthClientSecret/82ef4346187a4033a10d629cde07d740). - :type key_vault_id: str - """ - - _attribute_map = { - 'encrypted_secret': {'key': 'encryptedSecret', 'type': 'AsymmetricEncryptedSecret'}, - 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Secret, self).__init__(**kwargs) - self.encrypted_secret = kwargs.get('encrypted_secret', None) - self.key_vault_id = kwargs.get('key_vault_id', None) - - -class SecuritySettings(ARMBaseModel): - """The security settings of a device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: - ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) - self.device_admin_password = kwargs['device_admin_password'] - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification. - - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: - list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricSpecificationV1] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Share(ARMBaseModel): - """Represents a share on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Share on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share - (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2020_12_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the - share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2020_12_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2020_12_01.models.RefreshDetails - :ivar share_mappings: Share mount point to the role. - :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Share, self).__init__(**kwargs) - self.system_data = None - self.description = kwargs.get('description', None) - self.share_status = kwargs['share_status'] - self.monitoring_status = kwargs['monitoring_status'] - self.azure_container_info = kwargs.get('azure_container_info', None) - self.access_protocol = kwargs['access_protocol'] - self.user_access_rights = kwargs.get('user_access_rights', None) - self.client_access_rights = kwargs.get('client_access_rights', None) - self.refresh_details = kwargs.get('refresh_details', None) - self.share_mappings = None - self.data_policy = kwargs.get('data_policy', None) - - -class ShareAccessRight(msrest.serialization.Model): - """Specifies the mapping between this particular user and the type of access he has on shares on this device. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessType - """ - - _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.access_type = kwargs['access_type'] - - -class ShareList(msrest.serialization.Model): - """Collection of all the shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of shares. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Share] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Sku(msrest.serialization.Model): - """The SKU type. - - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". - :type name: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuTier - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - - -class SkuCapability(msrest.serialization.Model): - """The metadata to describe the capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: An invariant to describe the feature. - :vartype name: str - :ivar value: An invariant if the feature is measured by quantity. - :vartype value: str - """ - - _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuCapability, self).__init__(**kwargs) - self.name = None - self.value = None - - -class SkuCost(msrest.serialization.Model): - """The metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The cost quantity. - :vartype quantity: long - :ivar extended_unit: The extended unit. - :vartype extended_unit: str - """ - - _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, - } - - _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) - self.meter_id = None - self.quantity = None - self.extended_unit = None - - -class SkuInformation(msrest.serialization.Model): - """Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: The sku tier. - :vartype tier: str - :ivar kind: The sku kind. - :vartype kind: str - :ivar family: The Sku family. - :vartype family: str - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2020_12_01.models.SkuCost] - :ivar locations: The locations where Sku is available. - :vartype locations: list[str] - :ivar location_info: The locations where Sku is available with zones and sites info. - :vartype location_info: list[~azure.mgmt.databoxedge.v2020_12_01.models.SkuLocationInfo] - :ivar required_quota_ids: The required quotaIds for the sku to be available. - :vartype required_quota_ids: list[str] - :ivar required_features: The required features for the sku to be available. - :vartype required_features: list[str] - """ - - _validation = { - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'family': {'readonly': True}, - 'costs': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) - self.name = None - self.tier = None - self.kind = None - self.family = None - self.costs = None - self.locations = None - self.location_info = None - self.required_quota_ids = None - self.required_features = None - - -class SkuInformationList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceTypeSku objects. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.ResourceTypeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SkuLocationInfo(msrest.serialization.Model): - """The location info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The location. - :vartype location: str - :ivar zones: The zones. - :vartype zones: list[str] - :ivar sites: The sites. - :vartype sites: list[str] - """ - - _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) - self.location = None - self.zones = None - self.sites = None - - -class StorageAccount(ARMBaseModel): - """Represents a Storage Account on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: StorageAccount object on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or - ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountStatus - :param data_policy: Required. Data policy of the storage Account. Possible values include: - "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str - :ivar blob_endpoint: BlobEndpoint of Storage Account. - :vartype blob_endpoint: str - :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy - set to Cloud. - :vartype container_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'data_policy': {'required': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccount, self).__init__(**kwargs) - self.system_data = None - self.description = kwargs.get('description', None) - self.storage_account_status = kwargs.get('storage_account_status', None) - self.data_policy = kwargs['data_policy'] - self.storage_account_credential_id = kwargs.get('storage_account_credential_id', None) - self.blob_endpoint = None - self.container_count = None - - -class StorageAccountCredential(ARMBaseModel): - """The storage account credential. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: StorageAccountCredential object. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredential, self).__init__(**kwargs) - self.system_data = None - self.alias = kwargs['alias'] - self.user_name = kwargs.get('user_name', None) - self.account_key = kwargs.get('account_key', None) - self.connection_string = kwargs.get('connection_string', None) - self.ssl_status = kwargs['ssl_status'] - self.blob_domain_name = kwargs.get('blob_domain_name', None) - self.account_type = kwargs['account_type'] - self.storage_account_id = kwargs.get('storage_account_id', None) - - -class StorageAccountCredentialList(msrest.serialization.Model): - """The collection of storage account credentials. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class StorageAccountList(msrest.serialization.Model): - """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of storageAccounts. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SubscriptionRegisteredFeatures(msrest.serialization.Model): - """SubscriptionRegisteredFeatures. - - :param name: - :type name: str - :param state: - :type state: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionRegisteredFeatures, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.state = kwargs.get('state', None) - - -class SymmetricKey(msrest.serialization.Model): - """Symmetric key for authentication. - - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - """ - - _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) - self.connection_string = kwargs.get('connection_string', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type 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, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TrackingInfo(msrest.serialization.Model): - """Tracking courier information. - - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str - """ - - _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackingInfo, self).__init__(**kwargs) - self.serial_number = kwargs.get('serial_number', None) - self.carrier_name = kwargs.get('carrier_name', None) - self.tracking_id = kwargs.get('tracking_id', None) - self.tracking_url = kwargs.get('tracking_url', None) - - -class TriggerList(msrest.serialization.Model): - """Collection of all trigger on the data box edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of triggers. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Trigger] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UpdateDownloadProgress(msrest.serialization.Model): - """Details about the download progress of update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". - :vartype download_phase: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DownloadPhase - :ivar percent_complete: Percentage of completion. - :vartype percent_complete: int - :ivar total_bytes_to_download: Total bytes to download. - :vartype total_bytes_to_download: float - :ivar total_bytes_downloaded: Total bytes downloaded. - :vartype total_bytes_downloaded: float - :ivar number_of_updates_to_download: Number of updates to download. - :vartype number_of_updates_to_download: int - :ivar number_of_updates_downloaded: Number of updates downloaded. - :vartype number_of_updates_downloaded: int - """ - - _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, - } - - _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) - self.download_phase = None - self.percent_complete = None - self.total_bytes_to_download = None - self.total_bytes_downloaded = None - self.number_of_updates_to_download = None - self.number_of_updates_downloaded = None - - -class UpdateInstallProgress(msrest.serialization.Model): - """Progress details during installation of updates. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar percent_complete: Percentage completed. - :vartype percent_complete: int - :ivar number_of_updates_to_install: Number of updates to install. - :vartype number_of_updates_to_install: int - :ivar number_of_updates_installed: Number of updates installed. - :vartype number_of_updates_installed: int - """ - - _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, - } - - _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) - self.percent_complete = None - self.number_of_updates_to_install = None - self.number_of_updates_installed = None - - -class UpdateSummary(ARMBaseModel): - """Details about ongoing updates and availability of updates on the device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed - (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime - :ivar last_completed_download_job_date_time: The time when the last Download job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_download_job_date_time: ~datetime.datetime - :ivar last_completed_install_job_date_time: The time when the last Install job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_install_job_date_time: ~datetime.datetime - :ivar total_number_of_updates_available: The number of updates available for the current device - version as per the last device scan. - :vartype total_number_of_updates_available: int - :ivar total_number_of_updates_pending_download: The total number of items pending download. - :vartype total_number_of_updates_pending_download: int - :ivar total_number_of_updates_pending_install: The total number of items pending install. - :vartype total_number_of_updates_pending_install: int - :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.databoxedge.v2020_12_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". - :vartype ongoing_update_operation: str or - ~azure.mgmt.databoxedge.v2020_12_01.models.UpdateOperation - :ivar in_progress_download_job_id: The job ID of the download job in progress. - :vartype in_progress_download_job_id: str - :ivar in_progress_install_job_id: The job ID of the install job in progress. - :vartype in_progress_install_job_id: str - :ivar in_progress_download_job_started_date_time: The time when the currently running download - (if any) started. - :vartype in_progress_download_job_started_date_time: ~datetime.datetime - :ivar in_progress_install_job_started_date_time: The time when the currently running install - (if any) started. - :vartype in_progress_install_job_started_date_time: ~datetime.datetime - :ivar update_titles: The list of updates available for install. - :vartype update_titles: list[str] - :ivar total_update_size_in_bytes: The total size of updates available for download in bytes. - :vartype total_update_size_in_bytes: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateSummary, self).__init__(**kwargs) - self.device_version_number = kwargs.get('device_version_number', None) - self.friendly_device_version_name = kwargs.get('friendly_device_version_name', None) - self.device_last_scanned_date_time = kwargs.get('device_last_scanned_date_time', None) - self.last_completed_scan_job_date_time = kwargs.get('last_completed_scan_job_date_time', None) - self.last_completed_download_job_date_time = None - self.last_completed_install_job_date_time = None - self.total_number_of_updates_available = None - self.total_number_of_updates_pending_download = None - self.total_number_of_updates_pending_install = None - self.reboot_behavior = None - self.ongoing_update_operation = None - self.in_progress_download_job_id = None - self.in_progress_install_job_id = None - self.in_progress_download_job_started_date_time = None - self.in_progress_install_job_started_date_time = None - self.update_titles = None - self.total_update_size_in_bytes = None - - -class UploadCertificateRequest(msrest.serialization.Model): - """The upload certificate request. - - All required parameters must be populated in order to send to Azure. - - :param authentication_type: The authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str - """ - - _validation = { - 'certificate': {'required': True}, - } - - _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) - self.authentication_type = kwargs.get('authentication_type', None) - self.certificate = kwargs['certificate'] - - -class UploadCertificateResponse(msrest.serialization.Model): - """The upload registration certificate response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param auth_type: Specifies authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AuthenticationType - :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. - :vartype resource_id: str - :ivar aad_authority: Azure Active Directory tenant authority. - :vartype aad_authority: str - :ivar aad_tenant_id: Azure Active Directory tenant ID. - :vartype aad_tenant_id: str - :ivar service_principal_client_id: Azure Active Directory service principal client ID. - :vartype service_principal_client_id: str - :ivar service_principal_object_id: Azure Active Directory service principal object ID. - :vartype service_principal_object_id: str - :ivar azure_management_endpoint_audience: The azure management endpoint audience. - :vartype azure_management_endpoint_audience: str - :ivar aad_audience: Identifier of the target resource that is the recipient of the requested - token. - :vartype aad_audience: str - """ - - _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, - } - - _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) - self.auth_type = kwargs.get('auth_type', None) - self.resource_id = None - self.aad_authority = None - self.aad_tenant_id = None - self.service_principal_client_id = None - self.service_principal_object_id = None - self.azure_management_endpoint_audience = None - self.aad_audience = None - - -class User(ARMBaseModel): - """Represents a user who has access to one or more shares on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: User in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - :ivar share_access_rights: List of shares that the user has rights on. This field should not be - specified during user creation. - :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessRight] - :param user_type: Required. Type of the user. Possible values include: "Share", - "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.UserType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_access_rights': {'readonly': True}, - 'user_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.system_data = None - self.encrypted_password = kwargs.get('encrypted_password', None) - self.share_access_rights = None - self.user_type = kwargs['user_type'] - - -class UserAccessRight(msrest.serialization.Model): - """The mapping between a particular user and the access type on the SMB share. - - All required parameters must be populated in order to send to Azure. - - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessType - """ - - _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) - self.user_id = kwargs['user_id'] - self.access_type = kwargs['access_type'] - - -class UserList(msrest.serialization.Model): - """Collection of users. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of users. - :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.User] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) - self.value = None - self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_models_py3.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_models_py3.py index dd497b64f9f8..53ca076bb375 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_models_py3.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._data_box_edge_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ARMBaseModel(msrest.serialization.Model): +class ARMBaseModel(_serialization.Model): """Represents the base class for all object models. Variables are only populated by the server, and will be ignored when sending a request. @@ -28,22 +31,20 @@ class ARMBaseModel(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -52,8 +53,8 @@ def __init__( class Addon(ARMBaseModel): """Role Addon. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ArcAddon, IoTAddon. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ArcAddon, IoTAddon Variables are only populated by the server, and will be ignored when sending a request. @@ -65,43 +66,38 @@ class Addon(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - _subtype_map = { - 'kind': {'ArcForKubernetes': 'ArcAddon', 'IotEdge': 'IoTAddon'} - } + _subtype_map = {"kind": {"ArcForKubernetes": "ArcAddon", "IotEdge": "IoTAddon"}} - def __init__( - self, - **kwargs - ): - super(Addon, self).__init__(**kwargs) - self.kind = 'Addon' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None self.system_data = None -class AddonList(msrest.serialization.Model): +class AddonList(_serialization.Model): """Collection of all the Role addon on the Azure Stack Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -113,57 +109,55 @@ class AddonList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Addon]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Address(msrest.serialization.Model): +class Address(_serialization.Model): """The shipping address of the customer. All required parameters must be populated in order to send to Azure. - :param address_line1: The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: The postal code. - :type postal_code: str - :param city: The city name. - :type city: str - :param state: The state name. - :type state: str - :param country: Required. The country name. - :type country: str + :ivar address_line1: The address line1. + :vartype address_line1: str + :ivar address_line2: The address line2. + :vartype address_line2: str + :ivar address_line3: The address line3. + :vartype address_line3: str + :ivar postal_code: The postal code. + :vartype postal_code: str + :ivar city: The city name. + :vartype city: str + :ivar state: The state name. + :vartype state: str + :ivar country: The country name. Required. + :vartype country: str """ _validation = { - 'country': {'required': True}, + "country": {"required": True}, } _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, + "address_line1": {"key": "addressLine1", "type": "str"}, + "address_line2": {"key": "addressLine2", "type": "str"}, + "address_line3": {"key": "addressLine3", "type": "str"}, + "postal_code": {"key": "postalCode", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "country": {"key": "country", "type": "str"}, } def __init__( @@ -178,7 +172,23 @@ def __init__( state: Optional[str] = None, **kwargs ): - super(Address, self).__init__(**kwargs) + """ + :keyword address_line1: The address line1. + :paramtype address_line1: str + :keyword address_line2: The address line2. + :paramtype address_line2: str + :keyword address_line3: The address line3. + :paramtype address_line3: str + :keyword postal_code: The postal code. + :paramtype postal_code: str + :keyword city: The city name. + :paramtype city: str + :keyword state: The state name. + :paramtype state: str + :keyword country: The country name. Required. + :paramtype country: str + """ + super().__init__(**kwargs) self.address_line1 = address_line1 self.address_line2 = address_line2 self.address_line3 = address_line3 @@ -188,7 +198,7 @@ def __init__( self.country = country -class Alert(ARMBaseModel): +class Alert(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Alert on the data box edge/gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -209,7 +219,7 @@ class Alert(ARMBaseModel): :vartype appeared_at_date_time: ~datetime.datetime :ivar recommendation: Alert recommendation. :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", + :ivar severity: Severity of the alert. Known values are: "Informational", "Warning", and "Critical". :vartype severity: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AlertSeverity :ivar error_details: Error details of the alert. @@ -219,38 +229,36 @@ class Alert(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "title": {"readonly": True}, + "alert_type": {"readonly": True}, + "appeared_at_date_time": {"readonly": True}, + "recommendation": {"readonly": True}, + "severity": {"readonly": True}, + "error_details": {"readonly": True}, + "detailed_information": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "title": {"key": "properties.title", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "appeared_at_date_time": {"key": "properties.appearedAtDateTime", "type": "iso-8601"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "error_details": {"key": "properties.errorDetails", "type": "AlertErrorDetails"}, + "detailed_information": {"key": "properties.detailedInformation", "type": "{str}"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None self.title = None self.alert_type = None @@ -261,7 +269,7 @@ def __init__( self.detailed_information = None -class AlertErrorDetails(msrest.serialization.Model): +class AlertErrorDetails(_serialization.Model): """Error details for the alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -275,28 +283,26 @@ class AlertErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, + "error_code": {"readonly": True}, + "error_message": {"readonly": True}, + "occurrences": {"readonly": True}, } _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "occurrences": {"key": "occurrences", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_code = None self.error_message = None self.occurrences = None -class AlertList(msrest.serialization.Model): +class AlertList(_serialization.Model): """Collection of alerts. Variables are only populated by the server, and will be ignored when sending a request. @@ -308,25 +314,23 @@ class AlertList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ArcAddon(Addon): +class ArcAddon(Addon): # pylint: disable=too-many-instance-attributes """Arc Addon. Variables are only populated by the server, and will be ignored when sending a request. @@ -339,75 +343,78 @@ class ArcAddon(Addon): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param subscription_id: Required. Arc resource subscription Id. - :type subscription_id: str - :param resource_group_name: Required. Arc resource group name. - :type resource_group_name: str - :param resource_name: Required. Arc resource Name. - :type resource_name: str - :param resource_location: Required. Arc resource location. - :type resource_location: str + :ivar subscription_id: Arc resource subscription Id. Required. + :vartype subscription_id: str + :ivar resource_group_name: Arc resource group name. Required. + :vartype resource_group_name: str + :ivar resource_name: Arc resource Name. Required. + :vartype resource_name: str + :ivar resource_location: Arc resource location. Required. + :vartype resource_location: str :ivar version: Arc resource version. :vartype version: str - :ivar host_platform: Host OS supported by the Arc addon. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the Arc addon. Known values are: "Windows" and "Linux". :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'subscription_id': {'required': True}, - 'resource_group_name': {'required': True}, - 'resource_name': {'required': True}, - 'resource_location': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "subscription_id": {"required": True}, + "resource_group_name": {"required": True}, + "resource_name": {"required": True}, + "resource_location": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'properties.resourceGroupName', 'type': 'str'}, - 'resource_name': {'key': 'properties.resourceName', 'type': 'str'}, - 'resource_location': {'key': 'properties.resourceLocation', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "subscription_id": {"key": "properties.subscriptionId", "type": "str"}, + "resource_group_name": {"key": "properties.resourceGroupName", "type": "str"}, + "resource_name": {"key": "properties.resourceName", "type": "str"}, + "resource_location": {"key": "properties.resourceLocation", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( - self, - *, - subscription_id: str, - resource_group_name: str, - resource_name: str, - resource_location: str, - **kwargs + self, *, subscription_id: str, resource_group_name: str, resource_name: str, resource_location: str, **kwargs ): - super(ArcAddon, self).__init__(**kwargs) - self.kind = 'ArcForKubernetes' # type: str + """ + :keyword subscription_id: Arc resource subscription Id. Required. + :paramtype subscription_id: str + :keyword resource_group_name: Arc resource group name. Required. + :paramtype resource_group_name: str + :keyword resource_name: Arc resource Name. Required. + :paramtype resource_name: str + :keyword resource_location: Arc resource location. Required. + :paramtype resource_location: str + """ + super().__init__(**kwargs) + self.kind: str = "ArcForKubernetes" self.subscription_id = subscription_id self.resource_group_name = resource_group_name self.resource_name = resource_name @@ -418,94 +425,105 @@ def __init__( self.provisioning_state = None -class AsymmetricEncryptedSecret(msrest.serialization.Model): +class AsymmetricEncryptedSecret(_serialization.Model): """Represent the secrets intended for encryption with asymmetric key pair. All required parameters must be populated in order to send to Azure. - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + :ivar value: The value of the secret. Required. + :vartype value: str + :ivar encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or + :vartype encryption_cert_thumbprint: str + :ivar encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values are: + "None", "AES256", and "RSAES_PKCS1_v_1_5". + :vartype encryption_algorithm: str or ~azure.mgmt.databoxedge.v2020_12_01.models.EncryptionAlgorithm """ _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, + "value": {"required": True}, + "encryption_algorithm": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "encryption_cert_thumbprint": {"key": "encryptionCertThumbprint", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, } def __init__( self, *, value: str, - encryption_algorithm: Union[str, "EncryptionAlgorithm"], + encryption_algorithm: Union[str, "_models.EncryptionAlgorithm"], encryption_cert_thumbprint: Optional[str] = None, **kwargs ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) + """ + :keyword value: The value of the secret. Required. + :paramtype value: str + :keyword encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :paramtype encryption_cert_thumbprint: str + :keyword encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values + are: "None", "AES256", and "RSAES_PKCS1_v_1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.EncryptionAlgorithm + """ + super().__init__(**kwargs) self.value = value self.encryption_cert_thumbprint = encryption_cert_thumbprint self.encryption_algorithm = encryption_algorithm -class Authentication(msrest.serialization.Model): +class Authentication(_serialization.Model): """Authentication mechanism for IoT devices. - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2020_12_01.models.SymmetricKey + :ivar symmetric_key: Symmetric key for authentication. + :vartype symmetric_key: ~azure.mgmt.databoxedge.v2020_12_01.models.SymmetricKey """ _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, + "symmetric_key": {"key": "symmetricKey", "type": "SymmetricKey"}, } - def __init__( - self, - *, - symmetric_key: Optional["SymmetricKey"] = None, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) + def __init__(self, *, symmetric_key: Optional["_models.SymmetricKey"] = None, **kwargs): + """ + :keyword symmetric_key: Symmetric key for authentication. + :paramtype symmetric_key: ~azure.mgmt.databoxedge.v2020_12_01.models.SymmetricKey + """ + super().__init__(**kwargs) self.symmetric_key = symmetric_key -class AzureContainerInfo(msrest.serialization.Model): +class AzureContainerInfo(_serialization.Model): """Azure container mapping of the endpoint. All required parameters must be populated in order to send to Azure. - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerDataFormat + :ivar storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :vartype storage_account_credential_id: str + :ivar container_name: Container name (Based on the data format specified, this represents the + name of Azure Files/Page blob/Block blob). Required. + :vartype container_name: str + :ivar data_format: Storage format used for the file represented by the share. Required. Known + values are: "BlockBlob", "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerDataFormat """ _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, + "storage_account_credential_id": {"required": True}, + "container_name": {"required": True}, + "data_format": {"required": True}, } _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, + "storage_account_credential_id": {"key": "storageAccountCredentialId", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "data_format": {"key": "dataFormat", "type": "str"}, } def __init__( @@ -513,10 +531,22 @@ def __init__( *, storage_account_credential_id: str, container_name: str, - data_format: Union[str, "AzureContainerDataFormat"], + data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs ): - super(AzureContainerInfo, self).__init__(**kwargs) + """ + :keyword storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :paramtype storage_account_credential_id: str + :keyword container_name: Container name (Based on the data format specified, this represents + the name of Azure Files/Page blob/Block blob). Required. + :paramtype container_name: str + :keyword data_format: Storage format used for the file represented by the share. Required. + Known values are: "BlockBlob", "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.storage_account_credential_id = storage_account_credential_id self.container_name = container_name self.data_format = data_format @@ -537,48 +567,52 @@ class BandwidthSchedule(ARMBaseModel): :vartype type: str :ivar system_data: Bandwidth object related to ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2020_12_01.models.DayOfWeek] + :ivar start: The start time of the schedule in UTC. Required. + :vartype start: str + :ivar stop: The stop time of the schedule in UTC. Required. + :vartype stop: str + :ivar rate_in_mbps: The bandwidth rate in Mbps. Required. + :vartype rate_in_mbps: int + :ivar days: The days of the week when this schedule is applicable. Required. + :vartype days: list[str or ~azure.mgmt.databoxedge.v2020_12_01.models.DayOfWeek] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "start": {"required": True}, + "stop": {"required": True}, + "rate_in_mbps": {"required": True}, + "days": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "start": {"key": "properties.start", "type": "str"}, + "stop": {"key": "properties.stop", "type": "str"}, + "rate_in_mbps": {"key": "properties.rateInMbps", "type": "int"}, + "days": {"key": "properties.days", "type": "[str]"}, } def __init__( - self, - *, - start: str, - stop: str, - rate_in_mbps: int, - days: List[Union[str, "DayOfWeek"]], - **kwargs + self, *, start: str, stop: str, rate_in_mbps: int, days: List[Union[str, "_models.DayOfWeek"]], **kwargs ): - super(BandwidthSchedule, self).__init__(**kwargs) + """ + :keyword start: The start time of the schedule in UTC. Required. + :paramtype start: str + :keyword stop: The stop time of the schedule in UTC. Required. + :paramtype stop: str + :keyword rate_in_mbps: The bandwidth rate in Mbps. Required. + :paramtype rate_in_mbps: int + :keyword days: The days of the week when this schedule is applicable. Required. + :paramtype days: list[str or ~azure.mgmt.databoxedge.v2020_12_01.models.DayOfWeek] + """ + super().__init__(**kwargs) self.system_data = None self.start = start self.stop = stop @@ -586,7 +620,7 @@ def __init__( self.days = days -class BandwidthSchedulesList(msrest.serialization.Model): +class BandwidthSchedulesList(_serialization.Model): """The collection of bandwidth schedules. Variables are only populated by the server, and will be ignored when sending a request. @@ -598,54 +632,55 @@ class BandwidthSchedulesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BandwidthSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ClientAccessRight(msrest.serialization.Model): +class ClientAccessRight(_serialization.Model): """The mapping between a particular client IP and the type of access client has on the NFS share. All required parameters must be populated in order to send to Azure. - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ClientPermissionType + :ivar client: IP of the client. Required. + :vartype client: str + :ivar access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :vartype access_permission: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.ClientPermissionType """ _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, + "client": {"required": True}, + "access_permission": {"required": True}, } _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - *, - client: str, - access_permission: Union[str, "ClientPermissionType"], - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) + "client": {"key": "client", "type": "str"}, + "access_permission": {"key": "accessPermission", "type": "str"}, + } + + def __init__(self, *, client: str, access_permission: Union[str, "_models.ClientPermissionType"], **kwargs): + """ + :keyword client: IP of the client. Required. + :paramtype client: str + :keyword access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :paramtype access_permission: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.ClientPermissionType + """ + super().__init__(**kwargs) self.client = client self.access_permission = access_permission @@ -653,8 +688,8 @@ def __init__( class Role(ARMBaseModel): """Compute role. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole Variables are only populated by the server, and will be ignored when sending a request. @@ -666,39 +701,42 @@ class Role(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } _subtype_map = { - 'kind': {'CloudEdgeManagement': 'CloudEdgeManagementRole', 'IOT': 'IoTRole', 'Kubernetes': 'KubernetesRole', 'MEC': 'MECRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str + "kind": { + "CloudEdgeManagement": "CloudEdgeManagementRole", + "IOT": "IoTRole", + "Kubernetes": "KubernetesRole", + "MEC": "MECRole", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None self.system_data = None @@ -715,71 +753,70 @@ class CloudEdgeManagementRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :ivar local_management_status: Local Edge Management Status. Possible values include: - "Enabled", "Disabled". + :ivar local_management_status: Local Edge Management Status. Known values are: "Enabled" and + "Disabled". :vartype local_management_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus :ivar edge_profile: Edge Profile of the resource. :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfile - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'local_management_status': {'readonly': True}, - 'edge_profile': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "local_management_status": {"readonly": True}, + "edge_profile": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'local_management_status': {'key': 'properties.localManagementStatus', 'type': 'str'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - *, - role_status: Optional[Union[str, "RoleStatus"]] = None, - **kwargs - ): - super(CloudEdgeManagementRole, self).__init__(**kwargs) - self.kind = 'CloudEdgeManagement' # type: str + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "local_management_status": {"key": "properties.localManagementStatus", "type": "str"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, + } + + def __init__(self, *, role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs): + """ + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "CloudEdgeManagement" self.local_management_status = None self.edge_profile = None self.role_status = role_status -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2020_12_01.models.CloudErrorBody] + :vartype message: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.databoxedge.v2020_12_01.models.CloudErrorBody] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -787,16 +824,26 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): - super(CloudErrorBody, self).__init__(**kwargs) + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.databoxedge.v2020_12_01.models.CloudErrorBody] + """ + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class CniConfig(msrest.serialization.Model): +class CniConfig(_serialization.Model): """Cni configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -812,102 +859,102 @@ class CniConfig(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - 'pod_subnet': {'readonly': True}, - 'service_subnet': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, + "pod_subnet": {"readonly": True}, + "service_subnet": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'pod_subnet': {'key': 'podSubnet', 'type': 'str'}, - 'service_subnet': {'key': 'serviceSubnet', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "pod_subnet": {"key": "podSubnet", "type": "str"}, + "service_subnet": {"key": "serviceSubnet", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(CniConfig, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None self.pod_subnet = None self.service_subnet = None -class ComputeResource(msrest.serialization.Model): +class ComputeResource(_serialization.Model): """Compute infrastructure Resource. All required parameters must be populated in order to send to Azure. - :param processor_count: Required. Processor count. - :type processor_count: int - :param memory_in_gb: Required. Memory in GB. - :type memory_in_gb: long + :ivar processor_count: Processor count. Required. + :vartype processor_count: int + :ivar memory_in_gb: Memory in GB. Required. + :vartype memory_in_gb: int """ _validation = { - 'processor_count': {'required': True}, - 'memory_in_gb': {'required': True}, + "processor_count": {"required": True}, + "memory_in_gb": {"required": True}, } _attribute_map = { - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'long'}, - } - - def __init__( - self, - *, - processor_count: int, - memory_in_gb: int, - **kwargs - ): - super(ComputeResource, self).__init__(**kwargs) + "processor_count": {"key": "processorCount", "type": "int"}, + "memory_in_gb": {"key": "memoryInGB", "type": "int"}, + } + + def __init__(self, *, processor_count: int, memory_in_gb: int, **kwargs): + """ + :keyword processor_count: Processor count. Required. + :paramtype processor_count: int + :keyword memory_in_gb: Memory in GB. Required. + :paramtype memory_in_gb: int + """ + super().__init__(**kwargs) self.processor_count = processor_count self.memory_in_gb = memory_in_gb -class ContactDetails(msrest.serialization.Model): +class ContactDetails(_serialization.Model): """Contains all the contact details of the customer. All required parameters must be populated in order to send to Azure. - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] + :ivar contact_person: The contact person name. Required. + :vartype contact_person: str + :ivar company_name: The name of the company. Required. + :vartype company_name: str + :ivar phone: The phone number. Required. + :vartype phone: str + :ivar email_list: The email list. Required. + :vartype email_list: list[str] """ _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, + "contact_person": {"required": True}, + "company_name": {"required": True}, + "phone": {"required": True}, + "email_list": {"required": True}, } _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - *, - contact_person: str, - company_name: str, - phone: str, - email_list: List[str], - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) + "contact_person": {"key": "contactPerson", "type": "str"}, + "company_name": {"key": "companyName", "type": "str"}, + "phone": {"key": "phone", "type": "str"}, + "email_list": {"key": "emailList", "type": "[str]"}, + } + + def __init__(self, *, contact_person: str, company_name: str, phone: str, email_list: List[str], **kwargs): + """ + :keyword contact_person: The contact person name. Required. + :paramtype contact_person: str + :keyword company_name: The name of the company. Required. + :paramtype company_name: str + :keyword phone: The phone number. Required. + :paramtype phone: str + :keyword email_list: The email list. Required. + :paramtype email_list: list[str] + """ + super().__init__(**kwargs) self.contact_person = contact_person self.company_name = company_name self.phone = phone @@ -929,12 +976,13 @@ class Container(ARMBaseModel): :vartype type: str :ivar system_data: Container in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". + :ivar container_status: Current status of the container. Known values are: "OK", "Offline", + "Unknown", "Updating", and "NeedsAttention". :vartype container_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerDataFormat + :ivar data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerDataFormat :ivar refresh_details: Details of the refresh job on this container. :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_12_01.models.RefreshDetails :ivar created_date_time: The UTC time when container got created. @@ -942,34 +990,35 @@ class Container(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "container_status": {"readonly": True}, + "data_format": {"required": True}, + "refresh_details": {"readonly": True}, + "created_date_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - data_format: Union[str, "AzureContainerDataFormat"], - **kwargs - ): - super(Container, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "container_status": {"key": "properties.containerStatus", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, + } + + def __init__(self, *, data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs): + """ + :keyword data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.system_data = None self.container_status = None self.data_format = data_format @@ -977,7 +1026,7 @@ def __init__( self.created_date_time = None -class ContainerList(msrest.serialization.Model): +class ContainerList(_serialization.Model): """Collection of all the containers on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -989,25 +1038,23 @@ class ContainerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Container]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevice(ARMBaseModel): +class DataBoxEdgeDevice(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1020,29 +1067,29 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure + :ivar location: The location of the device. This is a supported and registered Azure geographical region (for example, West US, East US, or Southeast Asia). The geographical region of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2020_12_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceIdentity - :ivar kind: The etag for the devices. Possible values include: "AzureDataBoxGateway", - "AzureStackEdge", "AzureStackHub", "AzureModularDataCentre". + specified on update, the request will succeed. Required. + :vartype location: str + :ivar tags: The list of tags that describe the device. These tags can be used to view and group + this device (across resource groups). + :vartype tags: dict[str, str] + :ivar sku: The SKU type. + :vartype sku: ~azure.mgmt.databoxedge.v2020_12_01.models.Sku + :ivar etag: The etag for the devices. + :vartype etag: str + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceIdentity + :ivar kind: The etag for the devices. Known values are: "AzureDataBoxGateway", + "AzureStackEdge", "AzureStackHub", and "AzureModularDataCentre". :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceKind :ivar system_data: DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or + :ivar data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known values + are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :vartype data_box_edge_device_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceStatus :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. :vartype serial_number: str @@ -1050,8 +1097,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype description: str :ivar model_description: The description of the Data Box Edge/Gateway device model. :vartype model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". + :ivar device_type: The type of the Data Box Edge/Gateway device. "DataBoxEdgeDevice" :vartype device_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DeviceType :ivar friendly_name: The Data Box Edge/Gateway device name. :vartype friendly_name: str @@ -1062,7 +1108,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :ivar device_software_version: The Data Box Edge/Gateway device software version. :vartype device_software_version: str :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long + :vartype device_local_capacity: int :ivar time_zone: The Data Box Edge/Gateway device timezone. :vartype time_zone: str :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). @@ -1079,70 +1125,91 @@ class DataBoxEdgeDevice(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'system_data': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'description': {'readonly': True}, - 'model_description': {'readonly': True}, - 'device_type': {'readonly': True}, - 'friendly_name': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'edge_profile': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"readonly": True}, + "system_data": {"readonly": True}, + "serial_number": {"readonly": True}, + "description": {"readonly": True}, + "model_description": {"readonly": True}, + "device_type": {"readonly": True}, + "friendly_name": {"readonly": True}, + "culture": {"readonly": True}, + "device_model": {"readonly": True}, + "device_software_version": {"readonly": True}, + "device_local_capacity": {"readonly": True}, + "time_zone": {"readonly": True}, + "device_hcs_version": {"readonly": True}, + "configured_role_types": {"readonly": True}, + "node_count": {"readonly": True}, + "resource_move_details": {"readonly": True}, + "edge_profile": {"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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - 'resource_move_details': {'key': 'properties.resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - } - - def __init__( + "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}"}, + "sku": {"key": "sku", "type": "Sku"}, + "etag": {"key": "etag", "type": "str"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "data_box_edge_device_status": {"key": "properties.dataBoxEdgeDeviceStatus", "type": "str"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "model_description": {"key": "properties.modelDescription", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "culture": {"key": "properties.culture", "type": "str"}, + "device_model": {"key": "properties.deviceModel", "type": "str"}, + "device_software_version": {"key": "properties.deviceSoftwareVersion", "type": "str"}, + "device_local_capacity": {"key": "properties.deviceLocalCapacity", "type": "int"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "device_hcs_version": {"key": "properties.deviceHcsVersion", "type": "str"}, + "configured_role_types": {"key": "properties.configuredRoleTypes", "type": "[str]"}, + "node_count": {"key": "properties.nodeCount", "type": "int"}, + "resource_move_details": {"key": "properties.resourceMoveDetails", "type": "ResourceMoveDetails"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, etag: Optional[str] = None, - identity: Optional["ResourceIdentity"] = None, - data_box_edge_device_status: Optional[Union[str, "DataBoxEdgeDeviceStatus"]] = None, + identity: Optional["_models.ResourceIdentity"] = None, + data_box_edge_device_status: Optional[Union[str, "_models.DataBoxEdgeDeviceStatus"]] = None, **kwargs ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) + """ + :keyword location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :paramtype location: str + :keyword tags: The list of tags that describe the device. These tags can be used to view and + group this device (across resource groups). + :paramtype tags: dict[str, str] + :keyword sku: The SKU type. + :paramtype sku: ~azure.mgmt.databoxedge.v2020_12_01.models.Sku + :keyword etag: The etag for the devices. + :paramtype etag: str + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceIdentity + :keyword data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known + values are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :paramtype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceStatus + """ + super().__init__(**kwargs) self.location = location self.tags = tags self.sku = sku @@ -1168,7 +1235,7 @@ def __init__( self.edge_profile = None -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): +class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The extended Info of the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1179,26 +1246,26 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to + :ivar encryption_key_thumbprint: The digital signature of encrypted certificate. + :vartype encryption_key_thumbprint: str + :ivar encryption_key: The public part of the encryption certificate. Client uses this to encrypt any secret. - :type encryption_key: str + :vartype encryption_key: str :ivar resource_key: The Resource ID of the Resource. :vartype resource_key: str - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_version: str - :param key_vault_sync_status: Key vault sync status. Possible values include: "KeyVaultSynced", - "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", "KeyVaultSyncing". - :type key_vault_sync_status: str or + :vartype channel_integrity_key_version: str + :ivar key_vault_sync_status: Key vault sync status. Known values are: "KeyVaultSynced", + "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", and "KeyVaultSyncing". + :vartype key_vault_sync_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.KeyVaultSyncStatus :ivar device_secrets: Device secrets, will be returned only with ODataFilter $expand=deviceSecrets. @@ -1206,26 +1273,26 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - 'device_secrets': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_key": {"readonly": True}, + "device_secrets": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - 'client_secret_store_id': {'key': 'properties.clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'properties.clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'properties.channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'properties.channelIntegrityKeyVersion', 'type': 'str'}, - 'key_vault_sync_status': {'key': 'properties.keyVaultSyncStatus', 'type': 'str'}, - 'device_secrets': {'key': 'properties.deviceSecrets', 'type': 'DeviceSecrets'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encryption_key_thumbprint": {"key": "properties.encryptionKeyThumbprint", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "str"}, + "resource_key": {"key": "properties.resourceKey", "type": "str"}, + "client_secret_store_id": {"key": "properties.clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "properties.clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "properties.channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "properties.channelIntegrityKeyVersion", "type": "str"}, + "key_vault_sync_status": {"key": "properties.keyVaultSyncStatus", "type": "str"}, + "device_secrets": {"key": "properties.deviceSecrets", "type": "DeviceSecrets"}, } def __init__( @@ -1237,10 +1304,31 @@ def __init__( client_secret_store_url: Optional[str] = None, channel_integrity_key_name: Optional[str] = None, channel_integrity_key_version: Optional[str] = None, - key_vault_sync_status: Optional[Union[str, "KeyVaultSyncStatus"]] = None, + key_vault_sync_status: Optional[Union[str, "_models.KeyVaultSyncStatus"]] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) + """ + :keyword encryption_key_thumbprint: The digital signature of encrypted certificate. + :paramtype encryption_key_thumbprint: str + :keyword encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :paramtype encryption_key: str + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + :keyword key_vault_sync_status: Key vault sync status. Known values are: "KeyVaultSynced", + "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", and "KeyVaultSyncing". + :paramtype key_vault_sync_status: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.KeyVaultSyncStatus + """ + super().__init__(**kwargs) self.encryption_key_thumbprint = encryption_key_thumbprint self.encryption_key = encryption_key self.resource_key = None @@ -1252,32 +1340,32 @@ def __init__( self.device_secrets = None -class DataBoxEdgeDeviceExtendedInfoPatch(msrest.serialization.Model): +class DataBoxEdgeDeviceExtendedInfoPatch(_serialization.Model): """The Data Box Edge/Gateway device extended info patch. - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_version: str - :param sync_status: For changing or to initiate the resync to key-vault set the status to - KeyVaultSyncPending, rest of the status will not be applicable. Possible values include: - "KeyVaultSynced", "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", + :vartype channel_integrity_key_version: str + :ivar sync_status: For changing or to initiate the resync to key-vault set the status to + KeyVaultSyncPending, rest of the status will not be applicable. Known values are: + "KeyVaultSynced", "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", and "KeyVaultSyncing". - :type sync_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.KeyVaultSyncStatus + :vartype sync_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.KeyVaultSyncStatus """ _attribute_map = { - 'client_secret_store_id': {'key': 'clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'channelIntegrityKeyVersion', 'type': 'str'}, - 'sync_status': {'key': 'syncStatus', 'type': 'str'}, + "client_secret_store_id": {"key": "clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "channelIntegrityKeyVersion", "type": "str"}, + "sync_status": {"key": "syncStatus", "type": "str"}, } def __init__( @@ -1287,10 +1375,27 @@ def __init__( client_secret_store_url: Optional[str] = None, channel_integrity_key_name: Optional[str] = None, channel_integrity_key_version: Optional[str] = None, - sync_status: Optional[Union[str, "KeyVaultSyncStatus"]] = None, + sync_status: Optional[Union[str, "_models.KeyVaultSyncStatus"]] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfoPatch, self).__init__(**kwargs) + """ + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name for Channel Integrity Key stored in the Client + Key Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + :keyword sync_status: For changing or to initiate the resync to key-vault set the status to + KeyVaultSyncPending, rest of the status will not be applicable. Known values are: + "KeyVaultSynced", "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", and + "KeyVaultSyncing". + :paramtype sync_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.KeyVaultSyncStatus + """ + super().__init__(**kwargs) self.client_secret_store_id = client_secret_store_id self.client_secret_store_url = client_secret_store_url self.channel_integrity_key_name = channel_integrity_key_name @@ -1298,7 +1403,7 @@ def __init__( self.sync_status = sync_status -class DataBoxEdgeDeviceList(msrest.serialization.Model): +class DataBoxEdgeDeviceList(_serialization.Model): """The collection of Data Box Edge/Gateway devices. Variables are only populated by the server, and will be ignored when sending a request. @@ -1310,103 +1415,109 @@ class DataBoxEdgeDeviceList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevicePatch(msrest.serialization.Model): +class DataBoxEdgeDevicePatch(_serialization.Model): """The Data Box Edge/Gateway device patch. - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceIdentity - :param edge_profile: Edge Profile property of the Data Box Edge/Gateway device. - :type edge_profile: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfilePatch + :ivar tags: The tags attached to the Data Box Edge/Gateway resource. + :vartype tags: dict[str, str] + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceIdentity + :ivar edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfilePatch """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfilePatch'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfilePatch"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["ResourceIdentity"] = None, - edge_profile: Optional["EdgeProfilePatch"] = None, + identity: Optional["_models.ResourceIdentity"] = None, + edge_profile: Optional["_models.EdgeProfilePatch"] = None, **kwargs ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) + """ + :keyword tags: The tags attached to the Data Box Edge/Gateway resource. + :paramtype tags: dict[str, str] + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceIdentity + :keyword edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :paramtype edge_profile: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfilePatch + """ + super().__init__(**kwargs) self.tags = tags self.identity = identity self.edge_profile = edge_profile -class DataBoxEdgeMoveRequest(msrest.serialization.Model): +class DataBoxEdgeMoveRequest(_serialization.Model): """Resource Move details. All required parameters must be populated in order to send to Azure. - :param target_resource_group: Required. Target resource group ARMId. - :type target_resource_group: str - :param resources: Required. List of resources to be moved. - :type resources: list[str] + :ivar target_resource_group: Target resource group ARMId. Required. + :vartype target_resource_group: str + :ivar resources: List of resources to be moved. Required. + :vartype resources: list[str] """ _validation = { - 'target_resource_group': {'required': True}, - 'resources': {'required': True}, + "target_resource_group": {"required": True}, + "resources": {"required": True}, } _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[str]'}, - } - - def __init__( - self, - *, - target_resource_group: str, - resources: List[str], - **kwargs - ): - super(DataBoxEdgeMoveRequest, self).__init__(**kwargs) + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, + "resources": {"key": "resources", "type": "[str]"}, + } + + def __init__(self, *, target_resource_group: str, resources: List[str], **kwargs): + """ + :keyword target_resource_group: Target resource group ARMId. Required. + :paramtype target_resource_group: str + :keyword resources: List of resources to be moved. Required. + :paramtype resources: list[str] + """ + super().__init__(**kwargs) self.target_resource_group = target_resource_group self.resources = resources -class DataBoxEdgeSku(msrest.serialization.Model): +class DataBoxEdgeSku(_serialization.Model): # pylint: disable=too-many-instance-attributes """The Sku information. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". + :ivar name: The Sku name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", and "RDC". :vartype name: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuName :ivar kind: The Sku kind. :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". + :ivar tier: The Sku tier. "Standard" :vartype tier: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuTier :ivar size: The Sku kind. :vartype size: str @@ -1420,13 +1531,13 @@ class DataBoxEdgeSku(msrest.serialization.Model): :vartype location_info: list[~azure.mgmt.databoxedge.v2020_12_01.models.SkuLocationInfo] :ivar costs: The pricing info of the Sku. :vartype costs: list[~azure.mgmt.databoxedge.v2020_12_01.models.SkuCost] - :ivar signup_option: Sku can be signed up by customer or not. Possible values include: "None", + :ivar signup_option: Sku can be signed up by customer or not. Known values are: "None" and "Available". :vartype signup_option: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuSignupOption - :ivar version: Availability of the Sku as preview/stable. Possible values include: "Stable", + :ivar version: Availability of the Sku as preview/stable. Known values are: "Stable" and "Preview". :vartype version: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuVersion - :ivar availability: Links to the next set of results. Possible values include: "Available", + :ivar availability: Links to the next set of results. Known values are: "Available" and "Unavailable". :vartype availability: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuAvailability :ivar shipment_types: List of Shipment Types supported by this SKU. @@ -1436,46 +1547,44 @@ class DataBoxEdgeSku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - 'shipment_types': {'readonly': True}, - 'capabilities': {'readonly': True}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "kind": {"readonly": True}, + "tier": {"readonly": True}, + "size": {"readonly": True}, + "family": {"readonly": True}, + "locations": {"readonly": True}, + "api_versions": {"readonly": True}, + "location_info": {"readonly": True}, + "costs": {"readonly": True}, + "signup_option": {"readonly": True}, + "version": {"readonly": True}, + "availability": {"readonly": True}, + "shipment_types": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, - 'shipment_types': {'key': 'shipmentTypes', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SkuCapability]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "signup_option": {"key": "signupOption", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "availability": {"key": "availability", "type": "str"}, + "shipment_types": {"key": "shipmentTypes", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SkuCapability]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.kind = None @@ -1493,7 +1602,7 @@ def __init__( self.capabilities = None -class DataBoxEdgeSkuList(msrest.serialization.Model): +class DataBoxEdgeSkuList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -1505,95 +1614,125 @@ class DataBoxEdgeSkuList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DCAccessCode(msrest.serialization.Model): +class DCAccessCode(_serialization.Model): """DC Access code in the case of Self Managed Shipping. - :param auth_code: DCAccess Code for the Self Managed shipment. - :type auth_code: str + :ivar auth_code: DCAccess Code for the Self Managed shipment. + :vartype auth_code: str """ _attribute_map = { - 'auth_code': {'key': 'properties.authCode', 'type': 'str'}, + "auth_code": {"key": "properties.authCode", "type": "str"}, } - def __init__( - self, - *, - auth_code: Optional[str] = None, - **kwargs - ): - super(DCAccessCode, self).__init__(**kwargs) + def __init__(self, *, auth_code: Optional[str] = None, **kwargs): + """ + :keyword auth_code: DCAccess Code for the Self Managed shipment. + :paramtype auth_code: str + """ + super().__init__(**kwargs) self.auth_code = auth_code -class DeviceSecrets(msrest.serialization.Model): +class DeviceSecrets(_serialization.Model): """Device Secrets. - :param hcs_data_volume_bit_locker_external_key: Keyvault Id of + :ivar hcs_data_volume_bit_locker_external_key: Keyvault Id of HcsDataVolumeBitLockerExternalKey. - :type hcs_data_volume_bit_locker_external_key: + :vartype hcs_data_volume_bit_locker_external_key: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param hcs_internal_volume_bit_locker_external_key: Keyvault Id of + :ivar hcs_internal_volume_bit_locker_external_key: Keyvault Id of HcsInternalVolumeBitLockerExternalKey. - :type hcs_internal_volume_bit_locker_external_key: + :vartype hcs_internal_volume_bit_locker_external_key: + ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :ivar system_volume_bit_locker_recovery_key: Keyvault Id of SystemVolumeBitLockerRecoveryKey. + :vartype system_volume_bit_locker_recovery_key: + ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :ivar sed_encryption_external_key_id: Keyvault Id of SEDEncryptionExternalKeyId. + :vartype sed_encryption_external_key_id: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :ivar sed_encryption_external_key: Keyvault Id of SEDEncryptionExternalKey. + :vartype sed_encryption_external_key: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :ivar bmc_default_user_password: Keyvault Id of BMCDefaultUserPassword. + :vartype bmc_default_user_password: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :ivar rotate_key_for_data_volume_bitlocker: Keyvault Id of RotateKeyForDataVolumeBitlocker. + :vartype rotate_key_for_data_volume_bitlocker: + ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :ivar rotate_keys_for_sed_drives_serialized: Keyvault Id of RotateKeysForSedDrivesSerialized. + :vartype rotate_keys_for_sed_drives_serialized: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param system_volume_bit_locker_recovery_key: Keyvault Id of SystemVolumeBitLockerRecoveryKey. - :type system_volume_bit_locker_recovery_key: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param sed_encryption_external_key_id: Keyvault Id of SEDEncryptionExternalKeyId. - :type sed_encryption_external_key_id: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param sed_encryption_external_key: Keyvault Id of SEDEncryptionExternalKey. - :type sed_encryption_external_key: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param bmc_default_user_password: Keyvault Id of BMCDefaultUserPassword. - :type bmc_default_user_password: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param rotate_key_for_data_volume_bitlocker: Keyvault Id of RotateKeyForDataVolumeBitlocker. - :type rotate_key_for_data_volume_bitlocker: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret - :param rotate_keys_for_sed_drives_serialized: Keyvault Id of RotateKeysForSedDrivesSerialized. - :type rotate_keys_for_sed_drives_serialized: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret """ _attribute_map = { - 'hcs_data_volume_bit_locker_external_key': {'key': 'hcsDataVolumeBitLockerExternalKey', 'type': 'Secret'}, - 'hcs_internal_volume_bit_locker_external_key': {'key': 'hcsInternalVolumeBitLockerExternalKey', 'type': 'Secret'}, - 'system_volume_bit_locker_recovery_key': {'key': 'systemVolumeBitLockerRecoveryKey', 'type': 'Secret'}, - 'sed_encryption_external_key_id': {'key': 'sedEncryptionExternalKeyId', 'type': 'Secret'}, - 'sed_encryption_external_key': {'key': 'sedEncryptionExternalKey', 'type': 'Secret'}, - 'bmc_default_user_password': {'key': 'bmcDefaultUserPassword', 'type': 'Secret'}, - 'rotate_key_for_data_volume_bitlocker': {'key': 'rotateKeyForDataVolumeBitlocker', 'type': 'Secret'}, - 'rotate_keys_for_sed_drives_serialized': {'key': 'rotateKeysForSedDrivesSerialized', 'type': 'Secret'}, + "hcs_data_volume_bit_locker_external_key": {"key": "hcsDataVolumeBitLockerExternalKey", "type": "Secret"}, + "hcs_internal_volume_bit_locker_external_key": { + "key": "hcsInternalVolumeBitLockerExternalKey", + "type": "Secret", + }, + "system_volume_bit_locker_recovery_key": {"key": "systemVolumeBitLockerRecoveryKey", "type": "Secret"}, + "sed_encryption_external_key_id": {"key": "sedEncryptionExternalKeyId", "type": "Secret"}, + "sed_encryption_external_key": {"key": "sedEncryptionExternalKey", "type": "Secret"}, + "bmc_default_user_password": {"key": "bmcDefaultUserPassword", "type": "Secret"}, + "rotate_key_for_data_volume_bitlocker": {"key": "rotateKeyForDataVolumeBitlocker", "type": "Secret"}, + "rotate_keys_for_sed_drives_serialized": {"key": "rotateKeysForSedDrivesSerialized", "type": "Secret"}, } def __init__( self, *, - hcs_data_volume_bit_locker_external_key: Optional["Secret"] = None, - hcs_internal_volume_bit_locker_external_key: Optional["Secret"] = None, - system_volume_bit_locker_recovery_key: Optional["Secret"] = None, - sed_encryption_external_key_id: Optional["Secret"] = None, - sed_encryption_external_key: Optional["Secret"] = None, - bmc_default_user_password: Optional["Secret"] = None, - rotate_key_for_data_volume_bitlocker: Optional["Secret"] = None, - rotate_keys_for_sed_drives_serialized: Optional["Secret"] = None, + hcs_data_volume_bit_locker_external_key: Optional["_models.Secret"] = None, + hcs_internal_volume_bit_locker_external_key: Optional["_models.Secret"] = None, + system_volume_bit_locker_recovery_key: Optional["_models.Secret"] = None, + sed_encryption_external_key_id: Optional["_models.Secret"] = None, + sed_encryption_external_key: Optional["_models.Secret"] = None, + bmc_default_user_password: Optional["_models.Secret"] = None, + rotate_key_for_data_volume_bitlocker: Optional["_models.Secret"] = None, + rotate_keys_for_sed_drives_serialized: Optional["_models.Secret"] = None, **kwargs ): - super(DeviceSecrets, self).__init__(**kwargs) + """ + :keyword hcs_data_volume_bit_locker_external_key: Keyvault Id of + HcsDataVolumeBitLockerExternalKey. + :paramtype hcs_data_volume_bit_locker_external_key: + ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :keyword hcs_internal_volume_bit_locker_external_key: Keyvault Id of + HcsInternalVolumeBitLockerExternalKey. + :paramtype hcs_internal_volume_bit_locker_external_key: + ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :keyword system_volume_bit_locker_recovery_key: Keyvault Id of + SystemVolumeBitLockerRecoveryKey. + :paramtype system_volume_bit_locker_recovery_key: + ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :keyword sed_encryption_external_key_id: Keyvault Id of SEDEncryptionExternalKeyId. + :paramtype sed_encryption_external_key_id: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :keyword sed_encryption_external_key: Keyvault Id of SEDEncryptionExternalKey. + :paramtype sed_encryption_external_key: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :keyword bmc_default_user_password: Keyvault Id of BMCDefaultUserPassword. + :paramtype bmc_default_user_password: ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :keyword rotate_key_for_data_volume_bitlocker: Keyvault Id of RotateKeyForDataVolumeBitlocker. + :paramtype rotate_key_for_data_volume_bitlocker: + ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + :keyword rotate_keys_for_sed_drives_serialized: Keyvault Id of + RotateKeysForSedDrivesSerialized. + :paramtype rotate_keys_for_sed_drives_serialized: + ~azure.mgmt.databoxedge.v2020_12_01.models.Secret + """ + super().__init__(**kwargs) self.hcs_data_volume_bit_locker_external_key = hcs_data_volume_bit_locker_external_key self.hcs_internal_volume_bit_locker_external_key = hcs_internal_volume_bit_locker_external_key self.system_volume_bit_locker_recovery_key = system_volume_bit_locker_recovery_key @@ -1604,104 +1743,127 @@ def __init__( self.rotate_keys_for_sed_drives_serialized = rotate_keys_for_sed_drives_serialized -class EdgeProfile(msrest.serialization.Model): +class EdgeProfile(_serialization.Model): """Details about Edge Profile for the resource. - :param subscription: Edge Profile Subscription. - :type subscription: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfileSubscription + :ivar subscription: Edge Profile Subscription. + :vartype subscription: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfileSubscription """ _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscription'}, + "subscription": {"key": "subscription", "type": "EdgeProfileSubscription"}, } - def __init__( - self, - *, - subscription: Optional["EdgeProfileSubscription"] = None, - **kwargs - ): - super(EdgeProfile, self).__init__(**kwargs) + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscription"] = None, **kwargs): + """ + :keyword subscription: Edge Profile Subscription. + :paramtype subscription: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfileSubscription + """ + super().__init__(**kwargs) self.subscription = subscription -class EdgeProfilePatch(msrest.serialization.Model): +class EdgeProfilePatch(_serialization.Model): """The Data Box Edge/Gateway Edge Profile patch. - :param subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. - :type subscription: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfileSubscriptionPatch + :ivar subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :vartype subscription: ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfileSubscriptionPatch """ _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscriptionPatch'}, + "subscription": {"key": "subscription", "type": "EdgeProfileSubscriptionPatch"}, } - def __init__( - self, - *, - subscription: Optional["EdgeProfileSubscriptionPatch"] = None, - **kwargs - ): - super(EdgeProfilePatch, self).__init__(**kwargs) + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscriptionPatch"] = None, **kwargs): + """ + :keyword subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :paramtype subscription: + ~azure.mgmt.databoxedge.v2020_12_01.models.EdgeProfileSubscriptionPatch + """ + super().__init__(**kwargs) self.subscription = subscription -class EdgeProfileSubscription(msrest.serialization.Model): +class EdgeProfileSubscription(_serialization.Model): """Subscription details for the Edge Profile. - :param registration_id: Edge Subscription Registration ID. - :type registration_id: str - :param id: ARM ID of the subscription. - :type id: str - :param state: Possible values include: "Registered", "Warned", "Suspended", "Deleted", + :ivar registration_id: Edge Subscription Registration ID. + :vartype registration_id: str + :ivar id: ARM ID of the subscription. + :vartype id: str + :ivar state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and "Unregistered". - :type state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SubscriptionState - :param registration_date: - :type registration_date: str - :param subscription_id: - :type subscription_id: str - :param tenant_id: - :type tenant_id: str - :param location_placement_id: - :type location_placement_id: str - :param quota_id: - :type quota_id: str - :param serialized_details: - :type serialized_details: str - :param registered_features: - :type registered_features: + :vartype state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SubscriptionState + :ivar registration_date: + :vartype registration_date: str + :ivar subscription_id: + :vartype subscription_id: str + :ivar tenant_id: + :vartype tenant_id: str + :ivar location_placement_id: + :vartype location_placement_id: str + :ivar quota_id: + :vartype quota_id: str + :ivar serialized_details: + :vartype serialized_details: str + :ivar registered_features: + :vartype registered_features: list[~azure.mgmt.databoxedge.v2020_12_01.models.SubscriptionRegisteredFeatures] """ _attribute_map = { - 'registration_id': {'key': 'registrationId', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'registration_date': {'key': 'registrationDate', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'location_placement_id': {'key': 'properties.locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'properties.quotaId', 'type': 'str'}, - 'serialized_details': {'key': 'properties.serializedDetails', 'type': 'str'}, - 'registered_features': {'key': 'properties.registeredFeatures', 'type': '[SubscriptionRegisteredFeatures]'}, + "registration_id": {"key": "registrationId", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "registration_date": {"key": "registrationDate", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "location_placement_id": {"key": "properties.locationPlacementId", "type": "str"}, + "quota_id": {"key": "properties.quotaId", "type": "str"}, + "serialized_details": {"key": "properties.serializedDetails", "type": "str"}, + "registered_features": {"key": "properties.registeredFeatures", "type": "[SubscriptionRegisteredFeatures]"}, } def __init__( self, *, registration_id: Optional[str] = None, - id: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + state: Optional[Union[str, "_models.SubscriptionState"]] = None, registration_date: Optional[str] = None, subscription_id: Optional[str] = None, tenant_id: Optional[str] = None, location_placement_id: Optional[str] = None, quota_id: Optional[str] = None, serialized_details: Optional[str] = None, - registered_features: Optional[List["SubscriptionRegisteredFeatures"]] = None, + registered_features: Optional[List["_models.SubscriptionRegisteredFeatures"]] = None, **kwargs ): - super(EdgeProfileSubscription, self).__init__(**kwargs) + """ + :keyword registration_id: Edge Subscription Registration ID. + :paramtype registration_id: str + :keyword id: ARM ID of the subscription. + :paramtype id: str + :keyword state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and + "Unregistered". + :paramtype state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SubscriptionState + :keyword registration_date: + :paramtype registration_date: str + :keyword subscription_id: + :paramtype subscription_id: str + :keyword tenant_id: + :paramtype tenant_id: str + :keyword location_placement_id: + :paramtype location_placement_id: str + :keyword quota_id: + :paramtype quota_id: str + :keyword serialized_details: + :paramtype serialized_details: str + :keyword registered_features: + :paramtype registered_features: + list[~azure.mgmt.databoxedge.v2020_12_01.models.SubscriptionRegisteredFeatures] + """ + super().__init__(**kwargs) self.registration_id = registration_id self.id = id self.state = state @@ -1714,28 +1876,27 @@ def __init__( self.registered_features = registered_features -class EdgeProfileSubscriptionPatch(msrest.serialization.Model): +class EdgeProfileSubscriptionPatch(_serialization.Model): """The Data Box Edge/Gateway Edge Profile Subscription patch. - :param id: The path ID that uniquely identifies the subscription of the edge profile. - :type id: str + :ivar id: The path ID that uniquely identifies the subscription of the edge profile. + :vartype id: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): - super(EdgeProfileSubscriptionPatch, self).__init__(**kwargs) + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The path ID that uniquely identifies the subscription of the edge profile. + :paramtype id: str + """ + super().__init__(**kwargs) self.id = id -class EtcdInfo(msrest.serialization.Model): +class EtcdInfo(_serialization.Model): """Etcd configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1747,20 +1908,18 @@ class EtcdInfo(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(EtcdInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None @@ -1768,8 +1927,8 @@ def __init__( class Trigger(ARMBaseModel): """Trigger details. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FileEventTrigger, PeriodicTimerEventTrigger Variables are only populated by the server, and will be ignored when sending a request. @@ -1783,38 +1942,33 @@ class Trigger(ARMBaseModel): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.TriggerEventType + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.TriggerEventType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } + _subtype_map = {"kind": {"FileEvent": "FileEventTrigger", "PeriodicTimerEvent": "PeriodicTimerEventTrigger"}} - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None - self.kind = 'Trigger' # type: str + self.kind: Optional[str] = None class FileEventTrigger(Trigger): @@ -1832,100 +1986,108 @@ class FileEventTrigger(Trigger): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2020_12_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2020_12_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.TriggerEventType + :ivar source_info: File event source details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2020_12_01.models.FileSourceInfo + :ivar sink_info: Role sink info. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2020_12_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "FileSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "FileSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.FileSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str + """ + :keyword source_info: File event source details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2020_12_01.models.FileSourceInfo + :keyword sink_info: Role sink info. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2020_12_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "FileEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class FileSourceInfo(msrest.serialization.Model): +class FileSourceInfo(_serialization.Model): """File source details. All required parameters must be populated in order to send to Azure. - :param share_id: Required. File share ID. - :type share_id: str + :ivar share_id: File share ID. Required. + :vartype share_id: str """ _validation = { - 'share_id': {'required': True}, + "share_id": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: File share ID. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id -class GenerateCertResponse(msrest.serialization.Model): +class GenerateCertResponse(_serialization.Model): """Used in activation key generation flow. - :param public_key: Gets or sets base64 encoded certificate raw data, + :ivar public_key: Gets or sets base64 encoded certificate raw data, this is the public part needed to be uploaded to cert vault. - :type public_key: str - :param private_key: Gets or sets base64 encoded private part of the certificate, + :vartype public_key: str + :ivar private_key: Gets or sets base64 encoded private part of the certificate, needed to form the activation key. - :type private_key: str - :param expiry_time_in_utc: Gets or sets expiry time in UTC. - :type expiry_time_in_utc: str + :vartype private_key: str + :ivar expiry_time_in_utc: Gets or sets expiry time in UTC. + :vartype expiry_time_in_utc: str """ _attribute_map = { - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'expiry_time_in_utc': {'key': 'expiryTimeInUTC', 'type': 'str'}, + "public_key": {"key": "publicKey", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "expiry_time_in_utc": {"key": "expiryTimeInUTC", "type": "str"}, } def __init__( @@ -1936,34 +2098,44 @@ def __init__( expiry_time_in_utc: Optional[str] = None, **kwargs ): - super(GenerateCertResponse, self).__init__(**kwargs) + """ + :keyword public_key: Gets or sets base64 encoded certificate raw data, + this is the public part needed to be uploaded to cert vault. + :paramtype public_key: str + :keyword private_key: Gets or sets base64 encoded private part of the certificate, + needed to form the activation key. + :paramtype private_key: str + :keyword expiry_time_in_utc: Gets or sets expiry time in UTC. + :paramtype expiry_time_in_utc: str + """ + super().__init__(**kwargs) self.public_key = public_key self.private_key = private_key self.expiry_time_in_utc = expiry_time_in_utc -class ImageRepositoryCredential(msrest.serialization.Model): +class ImageRepositoryCredential(_serialization.Model): """Image repository credential. All required parameters must be populated in order to send to Azure. - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :ivar image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :vartype image_repository_url: str + :ivar user_name: Repository user name. Required. + :vartype user_name: str + :ivar password: Repository user password. + :vartype password: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret """ _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, + "image_repository_url": {"required": True}, + "user_name": {"required": True}, } _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, + "image_repository_url": {"key": "imageRepositoryUrl", "type": "str"}, + "user_name": {"key": "userName", "type": "str"}, + "password": {"key": "password", "type": "AsymmetricEncryptedSecret"}, } def __init__( @@ -1971,16 +2143,24 @@ def __init__( *, image_repository_url: str, user_name: str, - password: Optional["AsymmetricEncryptedSecret"] = None, + password: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs ): - super(ImageRepositoryCredential, self).__init__(**kwargs) + """ + :keyword image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :paramtype image_repository_url: str + :keyword user_name: Repository user name. Required. + :paramtype user_name: str + :keyword password: Repository user password. + :paramtype password: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.image_repository_url = image_repository_url self.user_name = user_name self.password = password -class IoTAddon(Addon): +class IoTAddon(Addon): # pylint: disable=too-many-instance-attributes """IoT Addon. Variables are only populated by the server, and will be ignored when sending a request. @@ -1993,67 +2173,74 @@ class IoTAddon(Addon): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param io_t_device_details: Required. IoT device metadata to which appliance needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo - :param io_t_edge_device_details: Required. IoT edge device to which the IoT Addon needs to be - configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo + :ivar io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be configured. + Required. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo :ivar version: Version of IoT running on the appliance. :vartype version: str - :ivar host_platform: Host OS supported by the IoT addon. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the IoT addon. Known values are: "Windows" and "Linux". :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AddonState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'io_t_device_details': {'required': True}, - 'io_t_edge_device_details': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "io_t_device_details": {"required": True}, + "io_t_edge_device_details": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - io_t_device_details: "IoTDeviceInfo", - io_t_edge_device_details: "IoTDeviceInfo", + io_t_device_details: "_models.IoTDeviceInfo", + io_t_edge_device_details: "_models.IoTDeviceInfo", **kwargs ): - super(IoTAddon, self).__init__(**kwargs) - self.kind = 'IotEdge' # type: str + """ + :keyword io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :paramtype io_t_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be + configured. Required. + :paramtype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo + """ + super().__init__(**kwargs) + self.kind: str = "IotEdge" self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details self.version = None @@ -2062,31 +2249,31 @@ def __init__( self.provisioning_state = None -class IoTDeviceInfo(msrest.serialization.Model): +class IoTDeviceInfo(_serialization.Model): """Metadata of IoT device/IoT Edge device to be configured. All required parameters must be populated in order to send to Azure. - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2020_12_01.models.Authentication + :ivar device_id: ID of the IoT device/edge device. Required. + :vartype device_id: str + :ivar io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :vartype io_t_host_hub: str + :ivar io_t_host_hub_id: Id for the IoT hub associated to the device. + :vartype io_t_host_hub_id: str + :ivar authentication: Encrypted IoT device/IoT edge device connection string. + :vartype authentication: ~azure.mgmt.databoxedge.v2020_12_01.models.Authentication """ _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, + "device_id": {"required": True}, + "io_t_host_hub": {"required": True}, } _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, + "device_id": {"key": "deviceId", "type": "str"}, + "io_t_host_hub": {"key": "ioTHostHub", "type": "str"}, + "io_t_host_hub_id": {"key": "ioTHostHubId", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, } def __init__( @@ -2095,38 +2282,48 @@ def __init__( device_id: str, io_t_host_hub: str, io_t_host_hub_id: Optional[str] = None, - authentication: Optional["Authentication"] = None, + authentication: Optional["_models.Authentication"] = None, **kwargs ): - super(IoTDeviceInfo, self).__init__(**kwargs) + """ + :keyword device_id: ID of the IoT device/edge device. Required. + :paramtype device_id: str + :keyword io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :paramtype io_t_host_hub: str + :keyword io_t_host_hub_id: Id for the IoT hub associated to the device. + :paramtype io_t_host_hub_id: str + :keyword authentication: Encrypted IoT device/IoT edge device connection string. + :paramtype authentication: ~azure.mgmt.databoxedge.v2020_12_01.models.Authentication + """ + super().__init__(**kwargs) self.device_id = device_id self.io_t_host_hub = io_t_host_hub self.io_t_host_hub_id = io_t_host_hub_id self.authentication = authentication -class IoTEdgeAgentInfo(msrest.serialization.Model): +class IoTEdgeAgentInfo(_serialization.Model): """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. All required parameters must be populated in order to send to Azure. - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: ~azure.mgmt.databoxedge.v2020_12_01.models.ImageRepositoryCredential + :ivar image_name: Name of the IoT edge agent image. Required. + :vartype image_name: str + :ivar tag: Image Tag. Required. + :vartype tag: str + :ivar image_repository: Image repository details. + :vartype image_repository: ~azure.mgmt.databoxedge.v2020_12_01.models.ImageRepositoryCredential """ _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, + "image_name": {"required": True}, + "tag": {"required": True}, } _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, + "image_name": {"key": "imageName", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "image_repository": {"key": "imageRepository", "type": "ImageRepositoryCredential"}, } def __init__( @@ -2134,16 +2331,25 @@ def __init__( *, image_name: str, tag: str, - image_repository: Optional["ImageRepositoryCredential"] = None, + image_repository: Optional["_models.ImageRepositoryCredential"] = None, **kwargs ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) + """ + :keyword image_name: Name of the IoT edge agent image. Required. + :paramtype image_name: str + :keyword tag: Image Tag. Required. + :paramtype tag: str + :keyword image_repository: Image repository details. + :paramtype image_repository: + ~azure.mgmt.databoxedge.v2020_12_01.models.ImageRepositoryCredential + """ + super().__init__(**kwargs) self.image_name = image_name self.tag = tag self.image_repository = image_repository -class IoTRole(Role): +class IoTRole(Role): # pylint: disable=too-many-instance-attributes """Compute role. Variables are only populated by the server, and will be ignored when sending a request. @@ -2156,72 +2362,92 @@ class IoTRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the IoT role. Known values are: "Windows" and "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType + :ivar io_t_device_details: IoT device metadata to which data box edge device needs to be connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo + :ivar share_mappings: Mount points of shares in role(s). + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] + :ivar io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :vartype io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTEdgeAgentInfo + :ivar host_platform_type: Platform where the Iot runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.HostPlatformType - :param compute_resource: Resource allocation. - :type compute_resource: ~azure.mgmt.databoxedge.v2020_12_01.models.ComputeResource - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus + :ivar compute_resource: Resource allocation. + :vartype compute_resource: ~azure.mgmt.databoxedge.v2020_12_01.models.ComputeResource + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'host_platform_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "host_platform_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'compute_resource': {'key': 'properties.computeResource', 'type': 'ComputeResource'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "io_t_edge_agent_info": {"key": "properties.ioTEdgeAgentInfo", "type": "IoTEdgeAgentInfo"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "compute_resource": {"key": "properties.computeResource", "type": "ComputeResource"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - io_t_device_details: Optional["IoTDeviceInfo"] = None, - io_t_edge_device_details: Optional["IoTDeviceInfo"] = None, - share_mappings: Optional[List["MountPointMap"]] = None, - io_t_edge_agent_info: Optional["IoTEdgeAgentInfo"] = None, - compute_resource: Optional["ComputeResource"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + io_t_device_details: Optional["_models.IoTDeviceInfo"] = None, + io_t_edge_device_details: Optional["_models.IoTDeviceInfo"] = None, + share_mappings: Optional[List["_models.MountPointMap"]] = None, + io_t_edge_agent_info: Optional["_models.IoTEdgeAgentInfo"] = None, + compute_resource: Optional["_models.ComputeResource"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str + """ + :keyword host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :paramtype host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType + :keyword io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :paramtype io_t_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT role needs to be + configured. + :paramtype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTDeviceInfo + :keyword share_mappings: Mount points of shares in role(s). + :paramtype share_mappings: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] + :keyword io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + runtime. + :paramtype io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_12_01.models.IoTEdgeAgentInfo + :keyword compute_resource: Resource allocation. + :paramtype compute_resource: ~azure.mgmt.databoxedge.v2020_12_01.models.ComputeResource + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "IOT" self.host_platform = host_platform self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details @@ -2232,7 +2458,7 @@ def __init__( self.role_status = role_status -class Ipv4Config(msrest.serialization.Model): +class Ipv4Config(_serialization.Model): """Details related to the IPv4 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2246,28 +2472,26 @@ class Ipv4Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "subnet": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.subnet = None self.gateway = None -class Ipv6Config(msrest.serialization.Model): +class Ipv6Config(_serialization.Model): """Details related to the IPv6 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2281,28 +2505,26 @@ class Ipv6Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "prefix_length": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "int"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.prefix_length = None self.gateway = None -class Job(msrest.serialization.Model): +class Job(_serialization.Model): # pylint: disable=too-many-instance-attributes """A device job. Variables are only populated by the server, and will be ignored when sending a request. @@ -2313,8 +2535,8 @@ class Job(msrest.serialization.Model): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar status: The current status of the job. Known values are: "Invalid", "Running", + "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.JobStatus :ivar start_time: The UTC date and time at which the job started. :vartype start_time: ~datetime.datetime @@ -2324,14 +2546,14 @@ class Job(msrest.serialization.Model): :vartype percent_complete: int :ivar error: The error details. :vartype error: ~azure.mgmt.databoxedge.v2020_12_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", + :ivar job_type: The type of the job. Known values are: "Invalid", "ScanForUpdates", "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer", "Backup", "Restore", - "TriggerSupportPackage". + and "TriggerSupportPackage". :vartype job_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", + :ivar current_stage: Current stage of the update operation. Known values are: "Unknown", "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". + "Success", "Failure", "RescanStarted", "RescanComplete", and "RescanFailed". :vartype current_stage: str or ~azure.mgmt.databoxedge.v2020_12_01.models.UpdateOperationStage :ivar download_progress: The download progress. :vartype download_progress: ~azure.mgmt.databoxedge.v2020_12_01.models.UpdateDownloadProgress @@ -2344,55 +2566,55 @@ class Job(msrest.serialization.Model): :vartype error_manifest_file: str :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str + :ivar folder: If only subfolders need to be refreshed, then the subfolder path inside the share + or container. (The path is empty if there are no subfolders.). + :vartype folder: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "error": {"readonly": True}, + "job_type": {"readonly": True}, + "current_stage": {"readonly": True}, + "download_progress": {"readonly": True}, + "install_progress": {"readonly": True}, + "total_refresh_errors": {"readonly": True}, + "error_manifest_file": {"readonly": True}, + "refreshed_entity_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - *, - folder: Optional[str] = None, - **kwargs - ): - super(Job, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "error": {"key": "error", "type": "JobErrorDetails"}, + "job_type": {"key": "properties.jobType", "type": "str"}, + "current_stage": {"key": "properties.currentStage", "type": "str"}, + "download_progress": {"key": "properties.downloadProgress", "type": "UpdateDownloadProgress"}, + "install_progress": {"key": "properties.installProgress", "type": "UpdateInstallProgress"}, + "total_refresh_errors": {"key": "properties.totalRefreshErrors", "type": "int"}, + "error_manifest_file": {"key": "properties.errorManifestFile", "type": "str"}, + "refreshed_entity_id": {"key": "properties.refreshedEntityId", "type": "str"}, + "folder": {"key": "properties.folder", "type": "str"}, + } + + def __init__(self, *, folder: Optional[str] = None, **kwargs): + """ + :keyword folder: If only subfolders need to be refreshed, then the subfolder path inside the + share or container. (The path is empty if there are no subfolders.). + :paramtype folder: str + """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2411,7 +2633,7 @@ def __init__( self.folder = folder -class JobErrorDetails(msrest.serialization.Model): +class JobErrorDetails(_serialization.Model): """The job error information containing the list of job errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -2425,28 +2647,26 @@ class JobErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "error_details": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "error_details": {"key": "errorDetails", "type": "[JobErrorItem]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_details = None self.code = None self.message = None -class JobErrorItem(msrest.serialization.Model): +class JobErrorItem(_serialization.Model): """The job error items. Variables are only populated by the server, and will be ignored when sending a request. @@ -2460,28 +2680,26 @@ class JobErrorItem(msrest.serialization.Model): """ _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "recommendations": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "recommendations": {"key": "recommendations", "type": "[str]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.recommendations = None self.code = None self.message = None -class KubernetesClusterInfo(msrest.serialization.Model): +class KubernetesClusterInfo(_serialization.Model): """Kubernetes cluster configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2492,66 +2710,64 @@ class KubernetesClusterInfo(msrest.serialization.Model): :vartype etcd_info: ~azure.mgmt.databoxedge.v2020_12_01.models.EtcdInfo :ivar nodes: Kubernetes cluster nodes. :vartype nodes: list[~azure.mgmt.databoxedge.v2020_12_01.models.NodeInfo] - :param version: Required. Kubernetes cluster version. - :type version: str + :ivar version: Kubernetes cluster version. Required. + :vartype version: str """ _validation = { - 'etcd_info': {'readonly': True}, - 'nodes': {'readonly': True}, - 'version': {'required': True}, + "etcd_info": {"readonly": True}, + "nodes": {"readonly": True}, + "version": {"required": True}, } _attribute_map = { - 'etcd_info': {'key': 'etcdInfo', 'type': 'EtcdInfo'}, - 'nodes': {'key': 'nodes', 'type': '[NodeInfo]'}, - 'version': {'key': 'version', 'type': 'str'}, + "etcd_info": {"key": "etcdInfo", "type": "EtcdInfo"}, + "nodes": {"key": "nodes", "type": "[NodeInfo]"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - *, - version: str, - **kwargs - ): - super(KubernetesClusterInfo, self).__init__(**kwargs) + def __init__(self, *, version: str, **kwargs): + """ + :keyword version: Kubernetes cluster version. Required. + :paramtype version: str + """ + super().__init__(**kwargs) self.etcd_info = None self.nodes = None self.version = version -class KubernetesIPConfiguration(msrest.serialization.Model): +class KubernetesIPConfiguration(_serialization.Model): """Kubernetes node IP configuration. Variables are only populated by the server, and will be ignored when sending a request. :ivar port: Port of the Kubernetes node. :vartype port: str - :param ip_address: IP address of the Kubernetes node. - :type ip_address: str + :ivar ip_address: IP address of the Kubernetes node. + :vartype ip_address: str """ _validation = { - 'port': {'readonly': True}, + "port": {"readonly": True}, } _attribute_map = { - 'port': {'key': 'port', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + "port": {"key": "port", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, } - def __init__( - self, - *, - ip_address: Optional[str] = None, - **kwargs - ): - super(KubernetesIPConfiguration, self).__init__(**kwargs) + def __init__(self, *, ip_address: Optional[str] = None, **kwargs): + """ + :keyword ip_address: IP address of the Kubernetes node. + :paramtype ip_address: str + """ + super().__init__(**kwargs) self.port = None self.ip_address = ip_address -class KubernetesRole(Role): +class KubernetesRole(Role): # pylint: disable=too-many-instance-attributes """Kubernetes role. Variables are only populated by the server, and will be ignored when sending a request. @@ -2564,64 +2780,78 @@ class KubernetesRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param host_platform: Host OS supported by the Kubernetes role. Possible values include: - "Windows", "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType - :ivar provisioning_state: State of Kubernetes deployment. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" and + "Linux". + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType + :ivar provisioning_state: State of Kubernetes deployment. Known values are: "Invalid", + "Creating", "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesState - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.HostPlatformType - :param kubernetes_cluster_info: Kubernetes cluster configuration. - :type kubernetes_cluster_info: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesClusterInfo - :param kubernetes_role_resources: Kubernetes role resources. - :type kubernetes_role_resources: + :ivar kubernetes_cluster_info: Kubernetes cluster configuration. + :vartype kubernetes_cluster_info: + ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesClusterInfo + :ivar kubernetes_role_resources: Kubernetes role resources. + :vartype kubernetes_role_resources: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleResources - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'host_platform_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "host_platform_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'kubernetes_cluster_info': {'key': 'properties.kubernetesClusterInfo', 'type': 'KubernetesClusterInfo'}, - 'kubernetes_role_resources': {'key': 'properties.kubernetesRoleResources', 'type': 'KubernetesRoleResources'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "kubernetes_cluster_info": {"key": "properties.kubernetesClusterInfo", "type": "KubernetesClusterInfo"}, + "kubernetes_role_resources": {"key": "properties.kubernetesRoleResources", "type": "KubernetesRoleResources"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - kubernetes_cluster_info: Optional["KubernetesClusterInfo"] = None, - kubernetes_role_resources: Optional["KubernetesRoleResources"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + kubernetes_cluster_info: Optional["_models.KubernetesClusterInfo"] = None, + kubernetes_role_resources: Optional["_models.KubernetesRoleResources"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(KubernetesRole, self).__init__(**kwargs) - self.kind = 'Kubernetes' # type: str + """ + :keyword host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" + and "Linux". + :paramtype host_platform: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PlatformType + :keyword kubernetes_cluster_info: Kubernetes cluster configuration. + :paramtype kubernetes_cluster_info: + ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesClusterInfo + :keyword kubernetes_role_resources: Kubernetes role resources. + :paramtype kubernetes_role_resources: + ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleResources + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "Kubernetes" self.host_platform = host_platform self.provisioning_state = None self.host_platform_type = None @@ -2630,46 +2860,45 @@ def __init__( self.role_status = role_status -class KubernetesRoleCompute(msrest.serialization.Model): +class KubernetesRoleCompute(_serialization.Model): """Kubernetes role compute resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param vm_profile: Required. VM profile. - :type vm_profile: str + :ivar vm_profile: VM profile. Required. + :vartype vm_profile: str :ivar memory_in_bytes: Memory in bytes. - :vartype memory_in_bytes: long + :vartype memory_in_bytes: int :ivar processor_count: Processor count. :vartype processor_count: int """ _validation = { - 'vm_profile': {'required': True}, - 'memory_in_bytes': {'readonly': True}, - 'processor_count': {'readonly': True}, + "vm_profile": {"required": True}, + "memory_in_bytes": {"readonly": True}, + "processor_count": {"readonly": True}, } _attribute_map = { - 'vm_profile': {'key': 'vmProfile', 'type': 'str'}, - 'memory_in_bytes': {'key': 'memoryInBytes', 'type': 'long'}, - 'processor_count': {'key': 'processorCount', 'type': 'int'}, + "vm_profile": {"key": "vmProfile", "type": "str"}, + "memory_in_bytes": {"key": "memoryInBytes", "type": "int"}, + "processor_count": {"key": "processorCount", "type": "int"}, } - def __init__( - self, - *, - vm_profile: str, - **kwargs - ): - super(KubernetesRoleCompute, self).__init__(**kwargs) + def __init__(self, *, vm_profile: str, **kwargs): + """ + :keyword vm_profile: VM profile. Required. + :paramtype vm_profile: str + """ + super().__init__(**kwargs) self.vm_profile = vm_profile self.memory_in_bytes = None self.processor_count = None -class KubernetesRoleNetwork(msrest.serialization.Model): +class KubernetesRoleNetwork(_serialization.Model): """Kubernetes role network resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2681,64 +2910,68 @@ class KubernetesRoleNetwork(msrest.serialization.Model): """ _validation = { - 'cni_config': {'readonly': True}, - 'load_balancer_config': {'readonly': True}, + "cni_config": {"readonly": True}, + "load_balancer_config": {"readonly": True}, } _attribute_map = { - 'cni_config': {'key': 'cniConfig', 'type': 'CniConfig'}, - 'load_balancer_config': {'key': 'loadBalancerConfig', 'type': 'LoadBalancerConfig'}, + "cni_config": {"key": "cniConfig", "type": "CniConfig"}, + "load_balancer_config": {"key": "loadBalancerConfig", "type": "LoadBalancerConfig"}, } - def __init__( - self, - **kwargs - ): - super(KubernetesRoleNetwork, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cni_config = None self.load_balancer_config = None -class KubernetesRoleResources(msrest.serialization.Model): +class KubernetesRoleResources(_serialization.Model): """Kubernetes role resources. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param storage: Kubernetes role storage resource. - :type storage: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleStorage - :param compute: Required. Kubernetes role compute resource. - :type compute: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleCompute + :ivar storage: Kubernetes role storage resource. + :vartype storage: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleStorage + :ivar compute: Kubernetes role compute resource. Required. + :vartype compute: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleCompute :ivar network: Kubernetes role network resource. :vartype network: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleNetwork """ _validation = { - 'compute': {'required': True}, - 'network': {'readonly': True}, + "compute": {"required": True}, + "network": {"readonly": True}, } _attribute_map = { - 'storage': {'key': 'storage', 'type': 'KubernetesRoleStorage'}, - 'compute': {'key': 'compute', 'type': 'KubernetesRoleCompute'}, - 'network': {'key': 'network', 'type': 'KubernetesRoleNetwork'}, + "storage": {"key": "storage", "type": "KubernetesRoleStorage"}, + "compute": {"key": "compute", "type": "KubernetesRoleCompute"}, + "network": {"key": "network", "type": "KubernetesRoleNetwork"}, } def __init__( self, *, - compute: "KubernetesRoleCompute", - storage: Optional["KubernetesRoleStorage"] = None, + compute: "_models.KubernetesRoleCompute", + storage: Optional["_models.KubernetesRoleStorage"] = None, **kwargs ): - super(KubernetesRoleResources, self).__init__(**kwargs) + """ + :keyword storage: Kubernetes role storage resource. + :paramtype storage: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleStorage + :keyword compute: Kubernetes role compute resource. Required. + :paramtype compute: ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleCompute + """ + super().__init__(**kwargs) self.storage = storage self.compute = compute self.network = None -class KubernetesRoleStorage(msrest.serialization.Model): +class KubernetesRoleStorage(_serialization.Model): """Kubernetes role storage resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2746,31 +2979,30 @@ class KubernetesRoleStorage(msrest.serialization.Model): :ivar storage_classes: Kubernetes storage class info. :vartype storage_classes: list[~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesRoleStorageClassInfo] - :param endpoints: Mount points of shares in role(s). - :type endpoints: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] + :ivar endpoints: Mount points of shares in role(s). + :vartype endpoints: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] """ _validation = { - 'storage_classes': {'readonly': True}, + "storage_classes": {"readonly": True}, } _attribute_map = { - 'storage_classes': {'key': 'storageClasses', 'type': '[KubernetesRoleStorageClassInfo]'}, - 'endpoints': {'key': 'endpoints', 'type': '[MountPointMap]'}, + "storage_classes": {"key": "storageClasses", "type": "[KubernetesRoleStorageClassInfo]"}, + "endpoints": {"key": "endpoints", "type": "[MountPointMap]"}, } - def __init__( - self, - *, - endpoints: Optional[List["MountPointMap"]] = None, - **kwargs - ): - super(KubernetesRoleStorage, self).__init__(**kwargs) + def __init__(self, *, endpoints: Optional[List["_models.MountPointMap"]] = None, **kwargs): + """ + :keyword endpoints: Mount points of shares in role(s). + :paramtype endpoints: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] + """ + super().__init__(**kwargs) self.storage_classes = None self.endpoints = endpoints -class KubernetesRoleStorageClassInfo(msrest.serialization.Model): +class KubernetesRoleStorageClassInfo(_serialization.Model): """Kubernetes storage class info. Variables are only populated by the server, and will be ignored when sending a request. @@ -2779,35 +3011,33 @@ class KubernetesRoleStorageClassInfo(msrest.serialization.Model): :vartype name: str :ivar type: Storage class type. :vartype type: str - :ivar posix_compliant: If provisioned storage is posix compliant. Possible values include: - "Invalid", "Enabled", "Disabled". + :ivar posix_compliant: If provisioned storage is posix compliant. Known values are: "Invalid", + "Enabled", and "Disabled". :vartype posix_compliant: str or ~azure.mgmt.databoxedge.v2020_12_01.models.PosixComplianceStatus """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'posix_compliant': {'readonly': True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "posix_compliant": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'posix_compliant': {'key': 'posixCompliant', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "posix_compliant": {"key": "posixCompliant", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorageClassInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.type = None self.posix_compliant = None -class LoadBalancerConfig(msrest.serialization.Model): +class LoadBalancerConfig(_serialization.Model): """Load balancer configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2819,20 +3049,18 @@ class LoadBalancerConfig(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(LoadBalancerConfig, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None @@ -2850,116 +3078,136 @@ class MECRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param connection_string: Activation key of the MEC. - :type connection_string: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus + :ivar connection_string: Activation key of the MEC. + :vartype connection_string: + ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'AsymmetricEncryptedSecret'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "connection_string": {"key": "properties.connectionString", "type": "AsymmetricEncryptedSecret"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(MECRole, self).__init__(**kwargs) - self.kind = 'MEC' # type: str + """ + :keyword connection_string: Activation key of the MEC. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "MEC" self.connection_string = connection_string self.role_status = role_status -class MetricConfiguration(msrest.serialization.Model): +class MetricConfiguration(_serialization.Model): """Metric configuration. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. The Resource ID on which the metrics should be pushed. - :type resource_id: str - :param mdm_account: The MDM account to which the counters should be pushed. - :type mdm_account: str - :param metric_name_space: The MDM namespace to which the counters should be pushed. This is + :ivar resource_id: The Resource ID on which the metrics should be pushed. Required. + :vartype resource_id: str + :ivar mdm_account: The MDM account to which the counters should be pushed. + :vartype mdm_account: str + :ivar metric_name_space: The MDM namespace to which the counters should be pushed. This is required if MDMAccount is specified. - :type metric_name_space: str - :param counter_sets: Required. Host name for the IoT hub associated to the device. - :type counter_sets: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricCounterSet] + :vartype metric_name_space: str + :ivar counter_sets: Host name for the IoT hub associated to the device. Required. + :vartype counter_sets: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricCounterSet] """ _validation = { - 'resource_id': {'required': True}, - 'counter_sets': {'required': True}, + "resource_id": {"required": True}, + "counter_sets": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'mdm_account': {'key': 'mdmAccount', 'type': 'str'}, - 'metric_name_space': {'key': 'metricNameSpace', 'type': 'str'}, - 'counter_sets': {'key': 'counterSets', 'type': '[MetricCounterSet]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "mdm_account": {"key": "mdmAccount", "type": "str"}, + "metric_name_space": {"key": "metricNameSpace", "type": "str"}, + "counter_sets": {"key": "counterSets", "type": "[MetricCounterSet]"}, } def __init__( self, *, resource_id: str, - counter_sets: List["MetricCounterSet"], + counter_sets: List["_models.MetricCounterSet"], mdm_account: Optional[str] = None, metric_name_space: Optional[str] = None, **kwargs ): - super(MetricConfiguration, self).__init__(**kwargs) + """ + :keyword resource_id: The Resource ID on which the metrics should be pushed. Required. + :paramtype resource_id: str + :keyword mdm_account: The MDM account to which the counters should be pushed. + :paramtype mdm_account: str + :keyword metric_name_space: The MDM namespace to which the counters should be pushed. This is + required if MDMAccount is specified. + :paramtype metric_name_space: str + :keyword counter_sets: Host name for the IoT hub associated to the device. Required. + :paramtype counter_sets: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricCounterSet] + """ + super().__init__(**kwargs) self.resource_id = resource_id self.mdm_account = mdm_account self.metric_name_space = metric_name_space self.counter_sets = counter_sets -class MetricCounter(msrest.serialization.Model): +class MetricCounter(_serialization.Model): """The metric counter. All required parameters must be populated in order to send to Azure. - :param name: Required. The counter name. - :type name: str - :param instance: The instance from which counter should be collected. - :type instance: str - :param dimension_filter: The dimension filter. - :type dimension_filter: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimension] - :param additional_dimensions: The additional dimensions to be added to metric. - :type additional_dimensions: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimension] + :ivar name: The counter name. Required. + :vartype name: str + :ivar instance: The instance from which counter should be collected. + :vartype instance: str + :ivar dimension_filter: The dimension filter. + :vartype dimension_filter: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimension] + :ivar additional_dimensions: The additional dimensions to be added to metric. + :vartype additional_dimensions: + list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimension] """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, - 'dimension_filter': {'key': 'dimensionFilter', 'type': '[MetricDimension]'}, - 'additional_dimensions': {'key': 'additionalDimensions', 'type': '[MetricDimension]'}, + "name": {"key": "name", "type": "str"}, + "instance": {"key": "instance", "type": "str"}, + "dimension_filter": {"key": "dimensionFilter", "type": "[MetricDimension]"}, + "additional_dimensions": {"key": "additionalDimensions", "type": "[MetricDimension]"}, } def __init__( @@ -2967,92 +3215,102 @@ def __init__( *, name: str, instance: Optional[str] = None, - dimension_filter: Optional[List["MetricDimension"]] = None, - additional_dimensions: Optional[List["MetricDimension"]] = None, + dimension_filter: Optional[List["_models.MetricDimension"]] = None, + additional_dimensions: Optional[List["_models.MetricDimension"]] = None, **kwargs ): - super(MetricCounter, self).__init__(**kwargs) + """ + :keyword name: The counter name. Required. + :paramtype name: str + :keyword instance: The instance from which counter should be collected. + :paramtype instance: str + :keyword dimension_filter: The dimension filter. + :paramtype dimension_filter: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimension] + :keyword additional_dimensions: The additional dimensions to be added to metric. + :paramtype additional_dimensions: + list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimension] + """ + super().__init__(**kwargs) self.name = name self.instance = instance self.dimension_filter = dimension_filter self.additional_dimensions = additional_dimensions -class MetricCounterSet(msrest.serialization.Model): +class MetricCounterSet(_serialization.Model): """The metric counter set. All required parameters must be populated in order to send to Azure. - :param counters: Required. The counters that should be collected in this set. - :type counters: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricCounter] + :ivar counters: The counters that should be collected in this set. Required. + :vartype counters: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricCounter] """ _validation = { - 'counters': {'required': True}, + "counters": {"required": True}, } _attribute_map = { - 'counters': {'key': 'counters', 'type': '[MetricCounter]'}, + "counters": {"key": "counters", "type": "[MetricCounter]"}, } - def __init__( - self, - *, - counters: List["MetricCounter"], - **kwargs - ): - super(MetricCounterSet, self).__init__(**kwargs) + def __init__(self, *, counters: List["_models.MetricCounter"], **kwargs): + """ + :keyword counters: The counters that should be collected in this set. Required. + :paramtype counters: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricCounter] + """ + super().__init__(**kwargs) self.counters = counters -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """The metric dimension. All required parameters must be populated in order to send to Azure. - :param source_type: Required. The dimension type. - :type source_type: str - :param source_name: Required. The dimension value. - :type source_name: str + :ivar source_type: The dimension type. Required. + :vartype source_type: str + :ivar source_name: The dimension value. Required. + :vartype source_name: str """ _validation = { - 'source_type': {'required': True}, - 'source_name': {'required': True}, + "source_type": {"required": True}, + "source_name": {"required": True}, } _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'source_name': {'key': 'sourceName', 'type': 'str'}, - } - - def __init__( - self, - *, - source_type: str, - source_name: str, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) + "source_type": {"key": "sourceType", "type": "str"}, + "source_name": {"key": "sourceName", "type": "str"}, + } + + def __init__(self, *, source_type: str, source_name: str, **kwargs): + """ + :keyword source_type: The dimension type. Required. + :paramtype source_type: str + :keyword source_name: The dimension value. Required. + :paramtype source_name: str + """ + super().__init__(**kwargs) self.source_type = source_type self.source_name = source_name -class MetricDimensionV1(msrest.serialization.Model): +class MetricDimensionV1(_serialization.Model): """Metric Dimension v1. - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the metrics dimension. + :vartype name: str + :ivar display_name: Display name of the metrics dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -3063,55 +3321,64 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(MetricDimensionV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metrics dimension. + :paramtype name: str + :keyword display_name: Display name of the metrics dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecificationV1(msrest.serialization.Model): +class MetricSpecificationV1(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric specification version 1. - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Description of the metric to be displayed. + :vartype display_description: str + :ivar unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :vartype unit: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricUnit + :ivar aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :vartype aggregation_type: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.MetricAggregationType + :ivar dimensions: Metric dimensions, other than default dimension which is resource. + :vartype dimensions: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimensionV1] + :ivar fill_gap_with_zero: Set true to fill the gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar category: Metric category. Known values are: "Capacity" and "Transaction". + :vartype category: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricCategory + :ivar resource_id_dimension_name_override: Resource name override. + :vartype resource_id_dimension_name_override: str + :ivar supported_time_grain_types: Support granularity of metrics. + :vartype supported_time_grain_types: list[str or ~azure.mgmt.databoxedge.v2020_12_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricAggregationType] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimensionV1]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, } def __init__( @@ -3120,17 +3387,46 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, display_description: Optional[str] = None, - unit: Optional[Union[str, "MetricUnit"]] = None, - aggregation_type: Optional[Union[str, "MetricAggregationType"]] = None, - dimensions: Optional[List["MetricDimensionV1"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, + dimensions: Optional[List["_models.MetricDimensionV1"]] = None, fill_gap_with_zero: Optional[bool] = None, - category: Optional[Union[str, "MetricCategory"]] = None, + category: Optional[Union[str, "_models.MetricCategory"]] = None, resource_id_dimension_name_override: Optional[str] = None, - supported_time_grain_types: Optional[List[Union[str, "TimeGrain"]]] = None, - supported_aggregation_types: Optional[List[Union[str, "MetricAggregationType"]]] = None, + supported_time_grain_types: Optional[List[Union[str, "_models.TimeGrain"]]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, **kwargs ): - super(MetricSpecificationV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Description of the metric to be displayed. + :paramtype display_description: str + :keyword unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :paramtype unit: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricUnit + :keyword aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :paramtype aggregation_type: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.MetricAggregationType + :keyword dimensions: Metric dimensions, other than default dimension which is resource. + :paramtype dimensions: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricDimensionV1] + :keyword fill_gap_with_zero: Set true to fill the gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: Metric category. Known values are: "Capacity" and "Transaction". + :paramtype category: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MetricCategory + :keyword resource_id_dimension_name_override: Resource name override. + :paramtype resource_id_dimension_name_override: str + :keyword supported_time_grain_types: Support granularity of metrics. + :paramtype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2020_12_01.models.TimeGrain] + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2020_12_01.models.MetricAggregationType] + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -3157,36 +3453,36 @@ class MonitoringMetricConfiguration(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param metric_configurations: Required. The metrics configuration details. - :type metric_configurations: + :ivar metric_configurations: The metrics configuration details. Required. + :vartype metric_configurations: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricConfiguration] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'metric_configurations': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "metric_configurations": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metric_configurations': {'key': 'properties.metricConfigurations', 'type': '[MetricConfiguration]'}, - } - - def __init__( - self, - *, - metric_configurations: List["MetricConfiguration"], - **kwargs - ): - super(MonitoringMetricConfiguration, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metric_configurations": {"key": "properties.metricConfigurations", "type": "[MetricConfiguration]"}, + } + + def __init__(self, *, metric_configurations: List["_models.MetricConfiguration"], **kwargs): + """ + :keyword metric_configurations: The metrics configuration details. Required. + :paramtype metric_configurations: + list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricConfiguration] + """ + super().__init__(**kwargs) self.metric_configurations = metric_configurations -class MonitoringMetricConfigurationList(msrest.serialization.Model): +class MonitoringMetricConfigurationList(_serialization.Model): """Collection of metric configurations. Variables are only populated by the server, and will be ignored when sending a request. @@ -3198,67 +3494,64 @@ class MonitoringMetricConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MonitoringMetricConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MonitoringMetricConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class MountPointMap(msrest.serialization.Model): +class MountPointMap(_serialization.Model): """The share mount point. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str + :ivar share_id: ID of the share mounted to the role VM. Required. + :vartype share_id: str :ivar role_id: ID of the role to which share is mounted. :vartype role_id: str :ivar mount_point: Mount point for the share. :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". + :ivar mount_type: Mounting type. Known values are: "Volume" and "HostPath". :vartype mount_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive", - "MEC", "CloudEdgeManagement", "Kubernetes". + :ivar role_type: Role type. Known values are: "IOT", "ASA", "Functions", "Cognitive", "MEC", + "CloudEdgeManagement", and "Kubernetes". :vartype role_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.RoleTypes """ _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, + "share_id": {"required": True}, + "role_id": {"readonly": True}, + "mount_point": {"readonly": True}, + "mount_type": {"readonly": True}, + "role_type": {"readonly": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "mount_point": {"key": "mountPoint", "type": "str"}, + "mount_type": {"key": "mountType", "type": "str"}, + "role_type": {"key": "roleType", "type": "str"}, + } + + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: ID of the share mounted to the role VM. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id self.role_id = None self.mount_point = None @@ -3266,7 +3559,7 @@ def __init__( self.role_type = None -class NetworkAdapter(msrest.serialization.Model): +class NetworkAdapter(_serialization.Model): # pylint: disable=too-many-instance-attributes """Represents the networkAdapter on a device. Variables are only populated by the server, and will be ignored when sending a request. @@ -3286,16 +3579,18 @@ class NetworkAdapter(msrest.serialization.Model): :ivar mac_address: MAC address. :vartype mac_address: str :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". + :vartype link_speed: int + :ivar status: Value indicating whether this adapter is valid. Known values are: "Inactive" and + "Active". :vartype status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterDHCPStatus + :ivar rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :vartype rdma_status: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterRDMAStatus + :ivar dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :vartype dhcp_status: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterDHCPStatus :ivar ipv4_configuration: The IPv4 configuration of the network adapter. :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2020_12_01.models.Ipv4Config :ivar ipv6_configuration: The IPv6 configuration of the network adapter. @@ -3307,47 +3602,57 @@ class NetworkAdapter(msrest.serialization.Model): """ _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, + "adapter_id": {"readonly": True}, + "adapter_position": {"readonly": True}, + "index": {"readonly": True}, + "node_id": {"readonly": True}, + "network_adapter_name": {"readonly": True}, + "label": {"readonly": True}, + "mac_address": {"readonly": True}, + "link_speed": {"readonly": True}, + "status": {"readonly": True}, + "ipv4_configuration": {"readonly": True}, + "ipv6_configuration": {"readonly": True}, + "ipv6_link_local_address": {"readonly": True}, + "dns_servers": {"readonly": True}, } _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, + "adapter_id": {"key": "adapterId", "type": "str"}, + "adapter_position": {"key": "adapterPosition", "type": "NetworkAdapterPosition"}, + "index": {"key": "index", "type": "int"}, + "node_id": {"key": "nodeId", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "mac_address": {"key": "macAddress", "type": "str"}, + "link_speed": {"key": "linkSpeed", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "rdma_status": {"key": "rdmaStatus", "type": "str"}, + "dhcp_status": {"key": "dhcpStatus", "type": "str"}, + "ipv4_configuration": {"key": "ipv4Configuration", "type": "Ipv4Config"}, + "ipv6_configuration": {"key": "ipv6Configuration", "type": "Ipv6Config"}, + "ipv6_link_local_address": {"key": "ipv6LinkLocalAddress", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, } def __init__( self, *, - rdma_status: Optional[Union[str, "NetworkAdapterRDMAStatus"]] = None, - dhcp_status: Optional[Union[str, "NetworkAdapterDHCPStatus"]] = None, + rdma_status: Optional[Union[str, "_models.NetworkAdapterRDMAStatus"]] = None, + dhcp_status: Optional[Union[str, "_models.NetworkAdapterDHCPStatus"]] = None, **kwargs ): - super(NetworkAdapter, self).__init__(**kwargs) + """ + :keyword rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :paramtype rdma_status: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterRDMAStatus + :keyword dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :paramtype dhcp_status: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkAdapterDHCPStatus + """ + super().__init__(**kwargs) self.adapter_id = None self.adapter_position = None self.index = None @@ -3365,32 +3670,30 @@ def __init__( self.dns_servers = None -class NetworkAdapterPosition(msrest.serialization.Model): +class NetworkAdapterPosition(_serialization.Model): """The network adapter position. Variables are only populated by the server, and will be ignored when sending a request. - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". + :ivar network_group: The network group. Known values are: "None", "NonRDMA", and "RDMA". :vartype network_group: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkGroup :ivar port: The port. :vartype port: int """ _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, + "network_group": {"readonly": True}, + "port": {"readonly": True}, } _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, + "network_group": {"key": "networkGroup", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_group = None self.port = None @@ -3411,89 +3714,85 @@ class NetworkSettings(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "network_adapters": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "network_adapters": {"key": "properties.networkAdapters", "type": "[NetworkAdapter]"}, } - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_adapters = None class Node(ARMBaseModel): """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str + Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node + Multi-node Edge devices will have more than 1 nodes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar node_status: The current status of the individual node. Known values are: "Unknown", + "Up", "Down", "Rebooting", and "ShuttingDown". + :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.NodeStatus + :ivar node_chassis_serial_number: Serial number of the Chassis. + :vartype node_chassis_serial_number: str + :ivar node_serial_number: Serial number of the individual node. + :vartype node_serial_number: str + :ivar node_display_name: Display Name of the individual node. + :vartype node_display_name: str + :ivar node_friendly_software_version: Friendly software version name that is currently + installed on the node. + :vartype node_friendly_software_version: str + :ivar node_hcs_version: HCS version that is currently installed on the node. + :vartype node_hcs_version: str + :ivar node_instance_id: Guid instance id of the node. + :vartype node_instance_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "node_status": {"readonly": True}, + "node_chassis_serial_number": {"readonly": True}, + "node_serial_number": {"readonly": True}, + "node_display_name": {"readonly": True}, + "node_friendly_software_version": {"readonly": True}, + "node_hcs_version": {"readonly": True}, + "node_instance_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "node_status": {"key": "properties.nodeStatus", "type": "str"}, + "node_chassis_serial_number": {"key": "properties.nodeChassisSerialNumber", "type": "str"}, + "node_serial_number": {"key": "properties.nodeSerialNumber", "type": "str"}, + "node_display_name": {"key": "properties.nodeDisplayName", "type": "str"}, + "node_friendly_software_version": {"key": "properties.nodeFriendlySoftwareVersion", "type": "str"}, + "node_hcs_version": {"key": "properties.nodeHcsVersion", "type": "str"}, + "node_instance_id": {"key": "properties.nodeInstanceId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.node_status = None self.node_chassis_serial_number = None self.node_serial_number = None @@ -3503,95 +3802,94 @@ def __init__( self.node_instance_id = None -class NodeInfo(msrest.serialization.Model): +class NodeInfo(_serialization.Model): """Kubernetes node info. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: Node name. :vartype name: str - :ivar type: Node type - Master/Worker. Possible values include: "Invalid", "Master", "Worker". + :ivar type: Node type - Master/Worker. Known values are: "Invalid", "Master", and "Worker". :vartype type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesNodeType - :param ip_configuration: IP Configuration of the Kubernetes node. - :type ip_configuration: + :ivar ip_configuration: IP Configuration of the Kubernetes node. + :vartype ip_configuration: list[~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesIPConfiguration] """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_configuration': {'key': 'ipConfiguration', 'type': '[KubernetesIPConfiguration]'}, - } - - def __init__( - self, - *, - ip_configuration: Optional[List["KubernetesIPConfiguration"]] = None, - **kwargs - ): - super(NodeInfo, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "ip_configuration": {"key": "ipConfiguration", "type": "[KubernetesIPConfiguration]"}, + } + + def __init__(self, *, ip_configuration: Optional[List["_models.KubernetesIPConfiguration"]] = None, **kwargs): + """ + :keyword ip_configuration: IP Configuration of the Kubernetes node. + :paramtype ip_configuration: + list[~azure.mgmt.databoxedge.v2020_12_01.models.KubernetesIPConfiguration] + """ + super().__init__(**kwargs) self.name = None self.type = None self.ip_configuration = ip_configuration -class NodeList(msrest.serialization.Model): +class NodeList(_serialization.Model): """Collection of Nodes. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of Nodes. :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Node] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Node]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: Optional[str] = None, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) + def __init__(self, *, next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = None self.next_link = next_link -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operations. - :param name: Name of the operation. - :type name: str - :param is_data_action: Is data action. - :type is_data_action: bool - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2020_12_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2020_12_01.models.ServiceSpecification + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Is data action. + :vartype is_data_action: bool + :ivar display: Properties displayed for the operation. + :vartype display: ~azure.mgmt.databoxedge.v2020_12_01.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar service_specification: Service specification. + :vartype service_specification: ~azure.mgmt.databoxedge.v2020_12_01.models.ServiceSpecification """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -3599,12 +3897,25 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): - super(Operation, self).__init__(**kwargs) + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Is data action. + :paramtype is_data_action: bool + :keyword display: Properties displayed for the operation. + :paramtype display: ~azure.mgmt.databoxedge.v2020_12_01.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword service_specification: Service specification. + :paramtype service_specification: + ~azure.mgmt.databoxedge.v2020_12_01.models.ServiceSpecification + """ + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -3612,24 +3923,24 @@ def __init__( self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display properties. - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: The type of resource in which the operation is performed. + :vartype resource: str + :ivar operation: Operation to be performed on the resource. + :vartype operation: str + :ivar description: Description of the operation to be performed. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -3641,46 +3952,56 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: The type of resource in which the operation is performed. + :paramtype resource: str + :keyword operation: Operation to be performed on the resource. + :paramtype operation: str + :keyword description: Description of the operation to be performed. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsList(msrest.serialization.Model): +class OperationsList(_serialization.Model): """The list of operations used for the discovery of available provider operations. All required parameters must be populated in order to send to Azure. - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar value: The value. Required. + :vartype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Operation] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: List["Operation"], - next_link: Optional[str] = None, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The value. Required. + :paramtype value: list[~azure.mgmt.databoxedge.v2020_12_01.models.Operation] + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Order(ARMBaseModel): +class Order(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The order details. Variables are only populated by the server, and will be ignored when sending a request. @@ -3691,10 +4012,10 @@ class Order(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2020_12_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2020_12_01.models.Address + :ivar contact_information: The contact details. + :vartype contact_information: ~azure.mgmt.databoxedge.v2020_12_01.models.ContactDetails + :ivar shipping_address: The shipping address. + :vartype shipping_address: ~azure.mgmt.databoxedge.v2020_12_01.models.Address :ivar current_status: Current status of the order. :vartype current_status: ~azure.mgmt.databoxedge.v2020_12_01.models.OrderStatus :ivar order_history: List of status changes in the order. @@ -3707,45 +4028,54 @@ class Order(ARMBaseModel): :ivar return_tracking_info: Tracking information for the package returned from the customer whether it has an original or a replacement device. :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2020_12_01.models.TrackingInfo] - :param shipment_type: ShipmentType of the order. Possible values include: "NotApplicable", - "ShippedToCustomer", "SelfPickup". - :type shipment_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShipmentType + :ivar shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :vartype shipment_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShipmentType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'current_status': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "current_status": {"readonly": True}, + "order_history": {"readonly": True}, + "serial_number": {"readonly": True}, + "delivery_tracking_info": {"readonly": True}, + "return_tracking_info": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - 'shipment_type': {'key': 'properties.shipmentType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "contact_information": {"key": "properties.contactInformation", "type": "ContactDetails"}, + "shipping_address": {"key": "properties.shippingAddress", "type": "Address"}, + "current_status": {"key": "properties.currentStatus", "type": "OrderStatus"}, + "order_history": {"key": "properties.orderHistory", "type": "[OrderStatus]"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "delivery_tracking_info": {"key": "properties.deliveryTrackingInfo", "type": "[TrackingInfo]"}, + "return_tracking_info": {"key": "properties.returnTrackingInfo", "type": "[TrackingInfo]"}, + "shipment_type": {"key": "properties.shipmentType", "type": "str"}, } def __init__( self, *, - contact_information: Optional["ContactDetails"] = None, - shipping_address: Optional["Address"] = None, - shipment_type: Optional[Union[str, "ShipmentType"]] = None, + contact_information: Optional["_models.ContactDetails"] = None, + shipping_address: Optional["_models.Address"] = None, + shipment_type: Optional[Union[str, "_models.ShipmentType"]] = None, **kwargs ): - super(Order, self).__init__(**kwargs) + """ + :keyword contact_information: The contact details. + :paramtype contact_information: ~azure.mgmt.databoxedge.v2020_12_01.models.ContactDetails + :keyword shipping_address: The shipping address. + :paramtype shipping_address: ~azure.mgmt.databoxedge.v2020_12_01.models.Address + :keyword shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :paramtype shipment_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShipmentType + """ + super().__init__(**kwargs) self.contact_information = contact_information self.shipping_address = shipping_address self.current_status = None @@ -3756,7 +4086,7 @@ def __init__( self.shipment_type = shipment_type -class OrderList(msrest.serialization.Model): +class OrderList(_serialization.Model): """List of order entities. Variables are only populated by the server, and will be ignored when sending a request. @@ -3768,41 +4098,39 @@ class OrderList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Order]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OrderStatus(msrest.serialization.Model): +class OrderStatus(_serialization.Model): """Represents a single status change. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", - "AwaitingPickup", "PickupCompleted", "AwaitingDrop". - :type status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.OrderState + :ivar status: Status of the order as per the allowed status types. Required. Known values are: + "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :vartype status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.OrderState :ivar update_date_time: Time of status update. :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str + :ivar comments: Comments related to this status change. + :vartype comments: str :ivar tracking_information: Tracking information related to the state in the ordering flow. :vartype tracking_information: ~azure.mgmt.databoxedge.v2020_12_01.models.TrackingInfo :ivar additional_order_details: Dictionary to hold generic information which is not stored @@ -3811,28 +4139,32 @@ class OrderStatus(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'tracking_information': {'readonly': True}, - 'additional_order_details': {'readonly': True}, + "status": {"required": True}, + "update_date_time": {"readonly": True}, + "tracking_information": {"readonly": True}, + "additional_order_details": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'tracking_information': {'key': 'trackingInformation', 'type': 'TrackingInfo'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - *, - status: Union[str, "OrderState"], - comments: Optional[str] = None, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) + "status": {"key": "status", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + "comments": {"key": "comments", "type": "str"}, + "tracking_information": {"key": "trackingInformation", "type": "TrackingInfo"}, + "additional_order_details": {"key": "additionalOrderDetails", "type": "{str}"}, + } + + def __init__(self, *, status: Union[str, "_models.OrderState"], comments: Optional[str] = None, **kwargs): + """ + :keyword status: Status of the order as per the allowed status types. Required. Known values + are: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :paramtype status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.OrderState + :keyword comments: Comments related to this status change. + :paramtype comments: str + """ + super().__init__(**kwargs) self.status = status self.update_date_time = None self.comments = comments @@ -3855,122 +4187,135 @@ class PeriodicTimerEventTrigger(Trigger): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2020_12_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2020_12_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_12_01.models.TriggerEventType + :ivar source_info: Periodic timer details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2020_12_01.models.PeriodicTimerSourceInfo + :ivar sink_info: Role Sink information. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2020_12_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "PeriodicTimerSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "PeriodicTimerSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.PeriodicTimerSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str + """ + :keyword source_info: Periodic timer details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2020_12_01.models.PeriodicTimerSourceInfo + :keyword sink_info: Role Sink information. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2020_12_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "PeriodicTimerEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class PeriodicTimerSourceInfo(msrest.serialization.Model): +class PeriodicTimerSourceInfo(_serialization.Model): """Periodic timer event source. All required parameters must be populated in order to send to Azure. - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str + :ivar start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :vartype start_time: ~datetime.datetime + :ivar schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :vartype schedule: str + :ivar topic: Topic where periodic events are published to IoT device. + :vartype topic: str """ _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, + "start_time": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - *, - start_time: datetime.datetime, - schedule: str, - topic: Optional[str] = None, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) + "start_time": {"key": "startTime", "type": "iso-8601"}, + "schedule": {"key": "schedule", "type": "str"}, + "topic": {"key": "topic", "type": "str"}, + } + + def __init__(self, *, start_time: datetime.datetime, schedule: str, topic: Optional[str] = None, **kwargs): + """ + :keyword start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :paramtype start_time: ~datetime.datetime + :keyword schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :paramtype schedule: str + :keyword topic: Topic where periodic events are published to IoT device. + :paramtype topic: str + """ + super().__init__(**kwargs) self.start_time = start_time self.schedule = schedule self.topic = topic -class RefreshDetails(msrest.serialization.Model): +class RefreshDetails(_serialization.Model): """Fields for tracking refresh job on the share or container. - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + :ivar in_progress_refresh_job_id: If a refresh job is currently in progress on this share or container, this field indicates the ARM resource ID of that job. The field is empty if no job is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh + :vartype in_progress_refresh_job_id: str + :ivar last_completed_refresh_job_time_in_utc: Indicates the completed time for the last refresh + job on this particular share or container, if any.This could be a failed job or a successful + job. + :vartype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :ivar error_manifest_file: Indicates the relative path of the error xml for the last refresh job on this particular share or container, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or + :vartype error_manifest_file: str + :ivar last_job: Indicates the id of the last refresh job on this particular share or container,if any. This could be a failed job or a successful job. - :type last_job: str + :vartype last_job: str """ _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, + "in_progress_refresh_job_id": {"key": "inProgressRefreshJobId", "type": "str"}, + "last_completed_refresh_job_time_in_utc": {"key": "lastCompletedRefreshJobTimeInUTC", "type": "iso-8601"}, + "error_manifest_file": {"key": "errorManifestFile", "type": "str"}, + "last_job": {"key": "lastJob", "type": "str"}, } def __init__( @@ -3982,20 +4327,37 @@ def __init__( last_job: Optional[str] = None, **kwargs ): - super(RefreshDetails, self).__init__(**kwargs) + """ + :keyword in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + container, this field indicates the ARM resource ID of that job. The field is empty if no job + is in progress. + :paramtype in_progress_refresh_job_id: str + :keyword last_completed_refresh_job_time_in_utc: Indicates the completed time for the last + refresh job on this particular share or container, if any.This could be a failed job or a + successful job. + :paramtype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :keyword error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share or container, if any. This could be a failed job or a successful + job. + :paramtype error_manifest_file: str + :keyword last_job: Indicates the id of the last refresh job on this particular share or + container,if any. This could be a failed job or a successful job. + :paramtype last_job: str + """ + super().__init__(**kwargs) self.in_progress_refresh_job_id = in_progress_refresh_job_id self.last_completed_refresh_job_time_in_utc = last_completed_refresh_job_time_in_utc self.error_manifest_file = error_manifest_file self.last_job = last_job -class ResourceIdentity(msrest.serialization.Model): +class ResourceIdentity(_serialization.Model): """Msi identity details of the resource. Variables are only populated by the server, and will be ignored when sending a request. - :param type: Identity type. Possible values include: "None", "SystemAssigned", "UserAssigned". - :type type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MsiIdentityType + :ivar type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :vartype type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MsiIdentityType :ivar principal_id: Service Principal Id backing the Msi. :vartype principal_id: str :ivar tenant_id: Home Tenant Id. @@ -4003,58 +4365,66 @@ class ResourceIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "MsiIdentityType"]] = None, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) + def __init__(self, *, type: Optional[Union[str, "_models.MsiIdentityType"]] = None, **kwargs): + """ + :keyword type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :paramtype type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MsiIdentityType + """ + super().__init__(**kwargs) self.type = type self.principal_id = None self.tenant_id = None -class ResourceMoveDetails(msrest.serialization.Model): +class ResourceMoveDetails(_serialization.Model): """Fields for tracking resource move. - :param operation_in_progress: Denotes whether move operation is in progress. Possible values - include: "None", "ResourceMoveInProgress", "ResourceMoveFailed". - :type operation_in_progress: str or + :ivar operation_in_progress: Denotes whether move operation is in progress. Known values are: + "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :vartype operation_in_progress: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceMoveStatus - :param operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + :ivar operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to finish. - :type operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + :vartype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime """ _attribute_map = { - 'operation_in_progress': {'key': 'operationInProgress', 'type': 'str'}, - 'operation_in_progress_lock_timeout_in_utc': {'key': 'operationInProgressLockTimeoutInUTC', 'type': 'iso-8601'}, + "operation_in_progress": {"key": "operationInProgress", "type": "str"}, + "operation_in_progress_lock_timeout_in_utc": {"key": "operationInProgressLockTimeoutInUTC", "type": "iso-8601"}, } def __init__( self, *, - operation_in_progress: Optional[Union[str, "ResourceMoveStatus"]] = None, + operation_in_progress: Optional[Union[str, "_models.ResourceMoveStatus"]] = None, operation_in_progress_lock_timeout_in_utc: Optional[datetime.datetime] = None, **kwargs ): - super(ResourceMoveDetails, self).__init__(**kwargs) + """ + :keyword operation_in_progress: Denotes whether move operation is in progress. Known values + are: "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :paramtype operation_in_progress: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.ResourceMoveStatus + :keyword operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + finish. + :paramtype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + """ + super().__init__(**kwargs) self.operation_in_progress = operation_in_progress self.operation_in_progress_lock_timeout_in_utc = operation_in_progress_lock_timeout_in_utc -class ResourceTypeSku(msrest.serialization.Model): +class ResourceTypeSku(_serialization.Model): """Resource type Sku object. Variables are only populated by the server, and will be ignored when sending a request. @@ -4066,25 +4436,23 @@ class ResourceTypeSku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'skus': {'readonly': True}, + "resource_type": {"readonly": True}, + "skus": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'skus': {'key': 'skus', 'type': '[SkuInformation]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "skus": {"key": "skus", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.skus = None -class RoleList(msrest.serialization.Model): +class RoleList(_serialization.Model): """Collection of all the roles on the Data Box Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4096,74 +4464,79 @@ class RoleList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Role]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RoleSinkInfo(msrest.serialization.Model): +class RoleSinkInfo(_serialization.Model): """Compute role against which events will be raised. All required parameters must be populated in order to send to Azure. - :param role_id: Required. Compute role ID. - :type role_id: str + :ivar role_id: Compute role ID. Required. + :vartype role_id: str """ _validation = { - 'role_id': {'required': True}, + "role_id": {"required": True}, } _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, + "role_id": {"key": "roleId", "type": "str"}, } - def __init__( - self, - *, - role_id: str, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) + def __init__(self, *, role_id: str, **kwargs): + """ + :keyword role_id: Compute role ID. Required. + :paramtype role_id: str + """ + super().__init__(**kwargs) self.role_id = role_id -class Secret(msrest.serialization.Model): +class Secret(_serialization.Model): """Holds device secret either as a KeyVault reference or as an encrypted value. - :param encrypted_secret: Encrypted (using device public key) secret value. - :type encrypted_secret: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - :param key_vault_id: Id of the Key-Vault where secret is stored (ex: + :ivar encrypted_secret: Encrypted (using device public key) secret value. + :vartype encrypted_secret: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :ivar key_vault_id: Id of the Key-Vault where secret is stored (ex: secrets/AuthClientSecret/82ef4346187a4033a10d629cde07d740). - :type key_vault_id: str + :vartype key_vault_id: str """ _attribute_map = { - 'encrypted_secret': {'key': 'encryptedSecret', 'type': 'AsymmetricEncryptedSecret'}, - 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, + "encrypted_secret": {"key": "encryptedSecret", "type": "AsymmetricEncryptedSecret"}, + "key_vault_id": {"key": "keyVaultId", "type": "str"}, } def __init__( self, *, - encrypted_secret: Optional["AsymmetricEncryptedSecret"] = None, + encrypted_secret: Optional["_models.AsymmetricEncryptedSecret"] = None, key_vault_id: Optional[str] = None, **kwargs ): - super(Secret, self).__init__(**kwargs) + """ + :keyword encrypted_secret: Encrypted (using device public key) secret value. + :paramtype encrypted_secret: + ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :keyword key_vault_id: Id of the Key-Vault where secret is stored (ex: + secrets/AuthClientSecret/82ef4346187a4033a10d629cde07d740). + :paramtype key_vault_id: str + """ + super().__init__(**kwargs) self.encrypted_secret = encrypted_secret self.key_vault_id = key_vault_id @@ -4181,61 +4554,64 @@ class SecuritySettings(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: + :ivar device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :vartype device_admin_password: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "device_admin_password": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - *, - device_admin_password: "AsymmetricEncryptedSecret", - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_admin_password": {"key": "properties.deviceAdminPassword", "type": "AsymmetricEncryptedSecret"}, + } + + def __init__(self, *, device_admin_password: "_models.AsymmetricEncryptedSecret", **kwargs): + """ + :keyword device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :paramtype device_admin_password: + ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.device_admin_password = device_admin_password -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification. - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: + :ivar metric_specifications: Metric specification as defined by shoebox. + :vartype metric_specifications: list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricSpecificationV1] """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecificationV1]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["MetricSpecificationV1"]] = None, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecificationV1"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specification as defined by shoebox. + :paramtype metric_specifications: + list[~azure.mgmt.databoxedge.v2020_12_01.models.MetricSpecificationV1] + """ + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Share(ARMBaseModel): +class Share(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Represents a share on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4250,76 +4626,105 @@ class Share(ARMBaseModel): :vartype type: str :ivar system_data: Share on ASE device. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share + :ivar description: Description for the share. + :vartype description: str + :ivar share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :vartype share_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareStatus + :ivar monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :vartype monitoring_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringStatus + :ivar azure_container_info: Azure container mapping for the share. + :vartype azure_container_info: ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerInfo + :ivar access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :vartype access_protocol: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessProtocol + :ivar user_access_rights: Mapping of users and corresponding access rights on the share (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2020_12_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the + :vartype user_access_rights: list[~azure.mgmt.databoxedge.v2020_12_01.models.UserAccessRight] + :ivar client_access_rights: List of IP addresses and corresponding access rights on the share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2020_12_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2020_12_01.models.RefreshDetails + :vartype client_access_rights: + list[~azure.mgmt.databoxedge.v2020_12_01.models.ClientAccessRight] + :ivar refresh_details: Details of the refresh job on this share. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_12_01.models.RefreshDetails :ivar share_mappings: Share mount point to the role. :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_12_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataPolicy + :ivar data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_status": {"required": True}, + "monitoring_status": {"required": True}, + "access_protocol": {"required": True}, + "share_mappings": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "share_status": {"key": "properties.shareStatus", "type": "str"}, + "monitoring_status": {"key": "properties.monitoringStatus", "type": "str"}, + "azure_container_info": {"key": "properties.azureContainerInfo", "type": "AzureContainerInfo"}, + "access_protocol": {"key": "properties.accessProtocol", "type": "str"}, + "user_access_rights": {"key": "properties.userAccessRights", "type": "[UserAccessRight]"}, + "client_access_rights": {"key": "properties.clientAccessRights", "type": "[ClientAccessRight]"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, } def __init__( self, *, - share_status: Union[str, "ShareStatus"], - monitoring_status: Union[str, "MonitoringStatus"], - access_protocol: Union[str, "ShareAccessProtocol"], + share_status: Union[str, "_models.ShareStatus"], + monitoring_status: Union[str, "_models.MonitoringStatus"], + access_protocol: Union[str, "_models.ShareAccessProtocol"], description: Optional[str] = None, - azure_container_info: Optional["AzureContainerInfo"] = None, - user_access_rights: Optional[List["UserAccessRight"]] = None, - client_access_rights: Optional[List["ClientAccessRight"]] = None, - refresh_details: Optional["RefreshDetails"] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, + azure_container_info: Optional["_models.AzureContainerInfo"] = None, + user_access_rights: Optional[List["_models.UserAccessRight"]] = None, + client_access_rights: Optional[List["_models.ClientAccessRight"]] = None, + refresh_details: Optional["_models.RefreshDetails"] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, **kwargs ): - super(Share, self).__init__(**kwargs) + """ + :keyword description: Description for the share. + :paramtype description: str + :keyword share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :paramtype share_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareStatus + :keyword monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :paramtype monitoring_status: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringStatus + :keyword azure_container_info: Azure container mapping for the share. + :paramtype azure_container_info: ~azure.mgmt.databoxedge.v2020_12_01.models.AzureContainerInfo + :keyword access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :paramtype access_protocol: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessProtocol + :keyword user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :paramtype user_access_rights: list[~azure.mgmt.databoxedge.v2020_12_01.models.UserAccessRight] + :keyword client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :paramtype client_access_rights: + list[~azure.mgmt.databoxedge.v2020_12_01.models.ClientAccessRight] + :keyword refresh_details: Details of the refresh job on this share. + :paramtype refresh_details: ~azure.mgmt.databoxedge.v2020_12_01.models.RefreshDetails + :keyword data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataPolicy + """ + super().__init__(**kwargs) self.system_data = None self.description = description self.share_status = share_status @@ -4333,41 +4738,42 @@ def __init__( self.data_policy = data_policy -class ShareAccessRight(msrest.serialization.Model): +class ShareAccessRight(_serialization.Model): """Specifies the mapping between this particular user and the type of access he has on shares on this device. All required parameters must be populated in order to send to Azure. - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessType + :ivar share_id: The share ID. Required. + :vartype share_id: str + :ivar access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessType """ _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, + "share_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, share_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword share_id: The share ID. Required. + :paramtype share_id: str + :keyword access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.share_id = share_id self.access_type = access_type -class ShareList(msrest.serialization.Model): +class ShareList(_serialization.Model): """Collection of all the shares on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4379,54 +4785,61 @@ class ShareList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Share]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU type. - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". - :type name: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuTier + :ivar name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", and "RDC". + :vartype name: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuTier """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "SkuName"]] = None, - tier: Optional[Union[str, "SkuTier"]] = None, + name: Optional[Union[str, "_models.SkuName"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, **kwargs ): - super(Sku, self).__init__(**kwargs) + """ + :keyword name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", and "RDC". + :paramtype name: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuName + :keyword tier: The SKU tier. This is based on the SKU name. "Standard" + :paramtype tier: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SkuTier + """ + super().__init__(**kwargs) self.name = name self.tier = tier -class SkuCapability(msrest.serialization.Model): +class SkuCapability(_serialization.Model): """The metadata to describe the capability. Variables are only populated by the server, and will be ignored when sending a request. @@ -4438,25 +4851,23 @@ class SkuCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuCost(msrest.serialization.Model): +class SkuCost(_serialization.Model): """The metadata for retrieving price info. Variables are only populated by the server, and will be ignored when sending a request. @@ -4464,34 +4875,32 @@ class SkuCost(msrest.serialization.Model): :ivar meter_id: Used for querying price from commerce. :vartype meter_id: str :ivar quantity: The cost quantity. - :vartype quantity: long + :vartype quantity: int :ivar extended_unit: The extended unit. :vartype extended_unit: str """ _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, + "meter_id": {"readonly": True}, + "quantity": {"readonly": True}, + "extended_unit": {"readonly": True}, } _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, + "meter_id": {"key": "meterId", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.meter_id = None self.quantity = None self.extended_unit = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Sku information. Variables are only populated by the server, and will be ignored when sending a request. @@ -4517,34 +4926,32 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'family': {'readonly': True}, - 'costs': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, + "name": {"readonly": True}, + "tier": {"readonly": True}, + "kind": {"readonly": True}, + "family": {"readonly": True}, + "costs": {"readonly": True}, + "locations": {"readonly": True}, + "location_info": {"readonly": True}, + "required_quota_ids": {"readonly": True}, + "required_features": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "required_quota_ids": {"key": "requiredQuotaIds", "type": "[str]"}, + "required_features": {"key": "requiredFeatures", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.tier = None self.kind = None @@ -4556,7 +4963,7 @@ def __init__( self.required_features = None -class SkuInformationList(msrest.serialization.Model): +class SkuInformationList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -4568,25 +4975,23 @@ class SkuInformationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceTypeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SkuLocationInfo(msrest.serialization.Model): +class SkuLocationInfo(_serialization.Model): """The location info. Variables are only populated by the server, and will be ignored when sending a request. @@ -4600,22 +5005,20 @@ class SkuLocationInfo(msrest.serialization.Model): """ _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, + "location": {"readonly": True}, + "zones": {"readonly": True}, + "sites": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "sites": {"key": "sites", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.zones = None self.sites = None @@ -4636,17 +5039,17 @@ class StorageAccount(ARMBaseModel): :vartype type: str :ivar system_data: StorageAccount object on ASE device. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or + :ivar description: Description for the storage Account. + :vartype description: str + :ivar storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :vartype storage_account_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountStatus - :param data_policy: Required. Data policy of the storage Account. Possible values include: - "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str + :ivar data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" and + "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataPolicy + :ivar storage_account_credential_id: Storage Account Credential Id. + :vartype storage_account_credential_id: str :ivar blob_endpoint: BlobEndpoint of Storage Account. :vartype blob_endpoint: str :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy @@ -4655,38 +5058,51 @@ class StorageAccount(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'data_policy': {'required': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "data_policy": {"required": True}, + "blob_endpoint": {"readonly": True}, + "container_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "storage_account_status": {"key": "properties.storageAccountStatus", "type": "str"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, + "storage_account_credential_id": {"key": "properties.storageAccountCredentialId", "type": "str"}, + "blob_endpoint": {"key": "properties.blobEndpoint", "type": "str"}, + "container_count": {"key": "properties.containerCount", "type": "int"}, } def __init__( self, *, - data_policy: Union[str, "DataPolicy"], + data_policy: Union[str, "_models.DataPolicy"], description: Optional[str] = None, - storage_account_status: Optional[Union[str, "StorageAccountStatus"]] = None, + storage_account_status: Optional[Union[str, "_models.StorageAccountStatus"]] = None, storage_account_credential_id: Optional[str] = None, **kwargs ): - super(StorageAccount, self).__init__(**kwargs) + """ + :keyword description: Description for the storage Account. + :paramtype description: str + :keyword storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :paramtype storage_account_status: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountStatus + :keyword data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" + and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DataPolicy + :keyword storage_account_credential_id: Storage Account Credential Id. + :paramtype storage_account_credential_id: str + """ + super().__init__(**kwargs) self.system_data = None self.description = description self.storage_account_status = storage_account_status @@ -4696,7 +5112,7 @@ def __init__( self.container_count = None -class StorageAccountCredential(ARMBaseModel): +class StorageAccountCredential(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The storage account credential. Variables are only populated by the server, and will be ignored when sending a request. @@ -4711,66 +5127,87 @@ class StorageAccountCredential(ARMBaseModel): :vartype type: str :ivar system_data: StorageAccountCredential object. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str + :ivar alias: Alias for the storage account. Required. + :vartype alias: str + :ivar user_name: Username for the storage account. + :vartype user_name: str + :ivar account_key: Encrypted storage key. + :vartype account_key: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string for the storage account. Use this string if username + and account key are not specified. + :vartype connection_string: str + :ivar ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values are: + "Enabled" and "Disabled". + :vartype ssl_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SSLStatus + :ivar blob_domain_name: Blob end point for private clouds. + :vartype blob_domain_name: str + :ivar account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :vartype account_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AccountType + :ivar storage_account_id: Id of the storage account. + :vartype storage_account_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "alias": {"required": True}, + "ssl_status": {"required": True}, + "account_type": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "alias": {"key": "properties.alias", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "account_key": {"key": "properties.accountKey", "type": "AsymmetricEncryptedSecret"}, + "connection_string": {"key": "properties.connectionString", "type": "str"}, + "ssl_status": {"key": "properties.sslStatus", "type": "str"}, + "blob_domain_name": {"key": "properties.blobDomainName", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, } def __init__( self, *, alias: str, - ssl_status: Union[str, "SSLStatus"], - account_type: Union[str, "AccountType"], + ssl_status: Union[str, "_models.SSLStatus"], + account_type: Union[str, "_models.AccountType"], user_name: Optional[str] = None, - account_key: Optional["AsymmetricEncryptedSecret"] = None, + account_key: Optional["_models.AsymmetricEncryptedSecret"] = None, connection_string: Optional[str] = None, blob_domain_name: Optional[str] = None, storage_account_id: Optional[str] = None, **kwargs ): - super(StorageAccountCredential, self).__init__(**kwargs) + """ + :keyword alias: Alias for the storage account. Required. + :paramtype alias: str + :keyword user_name: Username for the storage account. + :paramtype user_name: str + :keyword account_key: Encrypted storage key. + :paramtype account_key: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :keyword connection_string: Connection string for the storage account. Use this string if + username and account key are not specified. + :paramtype connection_string: str + :keyword ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values + are: "Enabled" and "Disabled". + :paramtype ssl_status: str or ~azure.mgmt.databoxedge.v2020_12_01.models.SSLStatus + :keyword blob_domain_name: Blob end point for private clouds. + :paramtype blob_domain_name: str + :keyword account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :paramtype account_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AccountType + :keyword storage_account_id: Id of the storage account. + :paramtype storage_account_id: str + """ + super().__init__(**kwargs) self.system_data = None self.alias = alias self.user_name = user_name @@ -4782,7 +5219,7 @@ def __init__( self.storage_account_id = storage_account_id -class StorageAccountCredentialList(msrest.serialization.Model): +class StorageAccountCredentialList(_serialization.Model): """The collection of storage account credentials. Variables are only populated by the server, and will be ignored when sending a request. @@ -4794,25 +5231,23 @@ class StorageAccountCredentialList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccountCredential]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountList(msrest.serialization.Model): +class StorageAccountList(_serialization.Model): """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4824,111 +5259,127 @@ class StorageAccountList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SubscriptionRegisteredFeatures(msrest.serialization.Model): +class SubscriptionRegisteredFeatures(_serialization.Model): """SubscriptionRegisteredFeatures. - :param name: - :type name: str - :param state: - :type state: str + :ivar name: + :vartype name: str + :ivar state: + :vartype state: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - state: Optional[str] = None, - **kwargs - ): - super(SubscriptionRegisteredFeatures, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, state: Optional[str] = None, **kwargs): + """ + :keyword name: + :paramtype name: str + :keyword state: + :paramtype state: str + """ + super().__init__(**kwargs) self.name = name self.state = state -class SymmetricKey(msrest.serialization.Model): +class SymmetricKey(_serialization.Model): """Symmetric key for authentication. - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string based on the symmetric key. + :vartype connection_string: + ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret """ _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, + "connection_string": {"key": "connectionString", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) + def __init__(self, *, connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs): + """ + :keyword connection_string: Connection string based on the symmetric key. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.connection_string = connection_string -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime + :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", and "Key". + :vartype created_by_type: str or ~azure.mgmt.databoxedge.v2020_12_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", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.CreatedByType + :ivar last_modified_at: The type of identity that last modified the resource. + :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'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_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, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(SystemData, self).__init__(**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", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.databoxedge.v2020_12_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", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.CreatedByType + :keyword last_modified_at: The type of identity that last modified the resource. + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -4937,24 +5388,24 @@ def __init__( self.last_modified_at = last_modified_at -class TrackingInfo(msrest.serialization.Model): +class TrackingInfo(_serialization.Model): """Tracking courier information. - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str + :ivar serial_number: Serial number of the device being tracked. + :vartype serial_number: str + :ivar carrier_name: Name of the carrier used in the delivery. + :vartype carrier_name: str + :ivar tracking_id: Tracking ID of the shipment. + :vartype tracking_id: str + :ivar tracking_url: Tracking URL of the shipment. + :vartype tracking_url: str """ _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, + "serial_number": {"key": "serialNumber", "type": "str"}, + "carrier_name": {"key": "carrierName", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "tracking_url": {"key": "trackingUrl", "type": "str"}, } def __init__( @@ -4966,14 +5417,24 @@ def __init__( tracking_url: Optional[str] = None, **kwargs ): - super(TrackingInfo, self).__init__(**kwargs) + """ + :keyword serial_number: Serial number of the device being tracked. + :paramtype serial_number: str + :keyword carrier_name: Name of the carrier used in the delivery. + :paramtype carrier_name: str + :keyword tracking_id: Tracking ID of the shipment. + :paramtype tracking_id: str + :keyword tracking_url: Tracking URL of the shipment. + :paramtype tracking_url: str + """ + super().__init__(**kwargs) self.serial_number = serial_number self.carrier_name = carrier_name self.tracking_id = tracking_id self.tracking_url = tracking_url -class TriggerList(msrest.serialization.Model): +class TriggerList(_serialization.Model): """Collection of all trigger on the data box edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4985,31 +5446,29 @@ class TriggerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Trigger]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class UpdateDownloadProgress(msrest.serialization.Model): +class UpdateDownloadProgress(_serialization.Model): """Details about the download progress of update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". + :ivar download_phase: The download phase. Known values are: "Unknown", "Initializing", + "Downloading", and "Verifying". :vartype download_phase: str or ~azure.mgmt.databoxedge.v2020_12_01.models.DownloadPhase :ivar percent_complete: Percentage of completion. :vartype percent_complete: int @@ -5024,28 +5483,26 @@ class UpdateDownloadProgress(msrest.serialization.Model): """ _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, + "download_phase": {"readonly": True}, + "percent_complete": {"readonly": True}, + "total_bytes_to_download": {"readonly": True}, + "total_bytes_downloaded": {"readonly": True}, + "number_of_updates_to_download": {"readonly": True}, + "number_of_updates_downloaded": {"readonly": True}, } _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, + "download_phase": {"key": "downloadPhase", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "total_bytes_to_download": {"key": "totalBytesToDownload", "type": "float"}, + "total_bytes_downloaded": {"key": "totalBytesDownloaded", "type": "float"}, + "number_of_updates_to_download": {"key": "numberOfUpdatesToDownload", "type": "int"}, + "number_of_updates_downloaded": {"key": "numberOfUpdatesDownloaded", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.download_phase = None self.percent_complete = None self.total_bytes_to_download = None @@ -5054,7 +5511,7 @@ def __init__( self.number_of_updates_downloaded = None -class UpdateInstallProgress(msrest.serialization.Model): +class UpdateInstallProgress(_serialization.Model): """Progress details during installation of updates. Variables are only populated by the server, and will be ignored when sending a request. @@ -5068,28 +5525,26 @@ class UpdateInstallProgress(msrest.serialization.Model): """ _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, + "percent_complete": {"readonly": True}, + "number_of_updates_to_install": {"readonly": True}, + "number_of_updates_installed": {"readonly": True}, } _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "number_of_updates_to_install": {"key": "numberOfUpdatesToInstall", "type": "int"}, + "number_of_updates_installed": {"key": "numberOfUpdatesInstalled", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.percent_complete = None self.number_of_updates_to_install = None self.number_of_updates_installed = None -class UpdateSummary(ARMBaseModel): +class UpdateSummary(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Details about ongoing updates and availability of updates on the device. Variables are only populated by the server, and will be ignored when sending a request. @@ -5100,15 +5555,15 @@ class UpdateSummary(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed + :ivar device_version_number: The current version of the device in format: 1.2.17312.13.",. + :vartype device_version_number: str + :ivar friendly_device_version_name: The current version of the device in text format. + :vartype friendly_device_version_name: str + :ivar device_last_scanned_date_time: The last time when a scan was done on the device. + :vartype device_last_scanned_date_time: ~datetime.datetime + :ivar last_completed_scan_job_date_time: The time when the last scan job was completed (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime + :vartype last_completed_scan_job_date_time: ~datetime.datetime :ivar last_completed_download_job_date_time: The time when the last Download job was completed (success/cancelled/failed) on the appliance. :vartype last_completed_download_job_date_time: ~datetime.datetime @@ -5123,11 +5578,11 @@ class UpdateSummary(ARMBaseModel): :ivar total_number_of_updates_pending_install: The total number of items pending install. :vartype total_number_of_updates_pending_install: int :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.databoxedge.v2020_12_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". + :ivar ongoing_update_operation: The current update operation. Known values are: "None", "Scan", + "Download", and "Install". :vartype ongoing_update_operation: str or ~azure.mgmt.databoxedge.v2020_12_01.models.UpdateOperation :ivar in_progress_download_job_id: The job ID of the download job in progress. @@ -5147,45 +5602,63 @@ class UpdateSummary(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_completed_download_job_date_time": {"readonly": True}, + "last_completed_install_job_date_time": {"readonly": True}, + "total_number_of_updates_available": {"readonly": True}, + "total_number_of_updates_pending_download": {"readonly": True}, + "total_number_of_updates_pending_install": {"readonly": True}, + "reboot_behavior": {"readonly": True}, + "ongoing_update_operation": {"readonly": True}, + "in_progress_download_job_id": {"readonly": True}, + "in_progress_install_job_id": {"readonly": True}, + "in_progress_download_job_started_date_time": {"readonly": True}, + "in_progress_install_job_started_date_time": {"readonly": True}, + "update_titles": {"readonly": True}, + "total_update_size_in_bytes": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_version_number": {"key": "properties.deviceVersionNumber", "type": "str"}, + "friendly_device_version_name": {"key": "properties.friendlyDeviceVersionName", "type": "str"}, + "device_last_scanned_date_time": {"key": "properties.deviceLastScannedDateTime", "type": "iso-8601"}, + "last_completed_scan_job_date_time": {"key": "properties.lastCompletedScanJobDateTime", "type": "iso-8601"}, + "last_completed_download_job_date_time": { + "key": "properties.lastCompletedDownloadJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_date_time": { + "key": "properties.lastCompletedInstallJobDateTime", + "type": "iso-8601", + }, + "total_number_of_updates_available": {"key": "properties.totalNumberOfUpdatesAvailable", "type": "int"}, + "total_number_of_updates_pending_download": { + "key": "properties.totalNumberOfUpdatesPendingDownload", + "type": "int", + }, + "total_number_of_updates_pending_install": { + "key": "properties.totalNumberOfUpdatesPendingInstall", + "type": "int", + }, + "reboot_behavior": {"key": "properties.rebootBehavior", "type": "str"}, + "ongoing_update_operation": {"key": "properties.ongoingUpdateOperation", "type": "str"}, + "in_progress_download_job_id": {"key": "properties.inProgressDownloadJobId", "type": "str"}, + "in_progress_install_job_id": {"key": "properties.inProgressInstallJobId", "type": "str"}, + "in_progress_download_job_started_date_time": { + "key": "properties.inProgressDownloadJobStartedDateTime", + "type": "iso-8601", + }, + "in_progress_install_job_started_date_time": { + "key": "properties.inProgressInstallJobStartedDateTime", + "type": "iso-8601", + }, + "update_titles": {"key": "properties.updateTitles", "type": "[str]"}, + "total_update_size_in_bytes": {"key": "properties.totalUpdateSizeInBytes", "type": "float"}, } def __init__( @@ -5197,7 +5670,18 @@ def __init__( last_completed_scan_job_date_time: Optional[datetime.datetime] = None, **kwargs ): - super(UpdateSummary, self).__init__(**kwargs) + """ + :keyword device_version_number: The current version of the device in format: 1.2.17312.13.",. + :paramtype device_version_number: str + :keyword friendly_device_version_name: The current version of the device in text format. + :paramtype friendly_device_version_name: str + :keyword device_last_scanned_date_time: The last time when a scan was done on the device. + :paramtype device_last_scanned_date_time: ~datetime.datetime + :keyword last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :paramtype last_completed_scan_job_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.device_version_number = device_version_number self.friendly_device_version_name = friendly_device_version_name self.device_last_scanned_date_time = device_last_scanned_date_time @@ -5217,47 +5701,56 @@ def __init__( self.total_update_size_in_bytes = None -class UploadCertificateRequest(msrest.serialization.Model): +class UploadCertificateRequest(_serialization.Model): """The upload certificate request. All required parameters must be populated in order to send to Azure. - :param authentication_type: The authentication type. Possible values include: "Invalid", + :ivar authentication_type: The authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str + :vartype authentication_type: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.AuthenticationType + :ivar certificate: The base64 encoded certificate raw data. Required. + :vartype certificate: str """ _validation = { - 'certificate': {'required': True}, + "certificate": {"required": True}, } _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "certificate": {"key": "properties.certificate", "type": "str"}, } def __init__( self, *, certificate: str, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs ): - super(UploadCertificateRequest, self).__init__(**kwargs) + """ + :keyword authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype authentication_type: str or + ~azure.mgmt.databoxedge.v2020_12_01.models.AuthenticationType + :keyword certificate: The base64 encoded certificate raw data. Required. + :paramtype certificate: str + """ + super().__init__(**kwargs) self.authentication_type = authentication_type self.certificate = certificate -class UploadCertificateResponse(msrest.serialization.Model): +class UploadCertificateResponse(_serialization.Model): """The upload registration certificate response. Variables are only populated by the server, and will be ignored when sending a request. - :param auth_type: Specifies authentication type. Possible values include: "Invalid", + :ivar auth_type: Specifies authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AuthenticationType + :vartype auth_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AuthenticationType :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. :vartype resource_id: str :ivar aad_authority: Azure Active Directory tenant authority. @@ -5276,33 +5769,33 @@ class UploadCertificateResponse(msrest.serialization.Model): """ _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, + "resource_id": {"readonly": True}, + "aad_authority": {"readonly": True}, + "aad_tenant_id": {"readonly": True}, + "service_principal_client_id": {"readonly": True}, + "service_principal_object_id": {"readonly": True}, + "azure_management_endpoint_audience": {"readonly": True}, + "aad_audience": {"readonly": True}, } _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - *, - auth_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) + "auth_type": {"key": "authType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "aad_authority": {"key": "aadAuthority", "type": "str"}, + "aad_tenant_id": {"key": "aadTenantId", "type": "str"}, + "service_principal_client_id": {"key": "servicePrincipalClientId", "type": "str"}, + "service_principal_object_id": {"key": "servicePrincipalObjectId", "type": "str"}, + "azure_management_endpoint_audience": {"key": "azureManagementEndpointAudience", "type": "str"}, + "aad_audience": {"key": "aadAudience", "type": "str"}, + } + + def __init__(self, *, auth_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs): + """ + :keyword auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype auth_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.AuthenticationType + """ + super().__init__(**kwargs) self.auth_type = auth_type self.resource_id = None self.aad_authority = None @@ -5328,84 +5821,94 @@ class User(ARMBaseModel): :vartype type: str :ivar system_data: User in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_12_01.models.SystemData - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :ivar encrypted_password: The password details. + :vartype encrypted_password: + ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret :ivar share_access_rights: List of shares that the user has rights on. This field should not be specified during user creation. :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessRight] - :param user_type: Required. Type of the user. Possible values include: "Share", - "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.UserType + :ivar user_type: Type of the user. Required. Known values are: "Share", "LocalManagement", and + "ARM". + :vartype user_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.UserType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_access_rights': {'readonly': True}, - 'user_type': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_access_rights": {"readonly": True}, + "user_type": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "encrypted_password": {"key": "properties.encryptedPassword", "type": "AsymmetricEncryptedSecret"}, + "share_access_rights": {"key": "properties.shareAccessRights", "type": "[ShareAccessRight]"}, + "user_type": {"key": "properties.userType", "type": "str"}, } def __init__( self, *, - user_type: Union[str, "UserType"], - encrypted_password: Optional["AsymmetricEncryptedSecret"] = None, + user_type: Union[str, "_models.UserType"], + encrypted_password: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs ): - super(User, self).__init__(**kwargs) + """ + :keyword encrypted_password: The password details. + :paramtype encrypted_password: + ~azure.mgmt.databoxedge.v2020_12_01.models.AsymmetricEncryptedSecret + :keyword user_type: Type of the user. Required. Known values are: "Share", "LocalManagement", + and "ARM". + :paramtype user_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.UserType + """ + super().__init__(**kwargs) self.system_data = None self.encrypted_password = encrypted_password self.share_access_rights = None self.user_type = user_type -class UserAccessRight(msrest.serialization.Model): +class UserAccessRight(_serialization.Model): """The mapping between a particular user and the access type on the SMB share. All required parameters must be populated in order to send to Azure. - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessType + :ivar user_id: User ID (already existing in the device). Required. + :vartype user_id: str + :ivar access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessType """ _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, + "user_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - user_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) + "user_id": {"key": "userId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, user_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword user_id: User ID (already existing in the device). Required. + :paramtype user_id: str + :keyword access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2020_12_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.user_id = user_id self.access_type = access_type -class UserList(msrest.serialization.Model): +class UserList(_serialization.Model): """Collection of users. Variables are only populated by the server, and will be ignored when sending a request. @@ -5417,19 +5920,17 @@ class UserList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[User]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/__init__.py index d70057be6458..febac852eb27 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/__init__.py @@ -25,23 +25,29 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'AddonsOperations', - 'MonitoringConfigOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_addons_operations.py index 09c62f5d0066..1476b979fcd0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_addons_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,114 +6,274 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_role_request( + device_name: str, role_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, addon_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class AddonsOperations(object): - """AddonsOperations operations. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`addons` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_role( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AddonList"] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Addon"]: """Lists all the addons configured in the role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AddonList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_role.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,122 +282,133 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_role.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + @distributed_trace def get( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Addon" + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: """Gets a specific addon by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } def _create_or_update_initial( self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Addon"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Addon"]] + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(addon, 'Addon') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -245,53 +417,143 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Addon"] + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: """Create or update a addon. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param addon: The addon properties. + :param addon: The addon properties. Required. :type addon: ~azure.mgmt.databoxedge.v2020_12_01.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Addon or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2020_12_01.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -299,80 +561,75 @@ def begin_create_or_update( addon_name=addon_name, resource_group_name=resource_group_name, addon=addon, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -382,79 +639,79 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the addon on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, addon_name=addon_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_alerts_operations.py index f77ba9c4b82e..bde4f5d128b8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class AlertsOperations(object): - """AlertsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_by_data_box_edge_device_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,72 +206,73 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_available_skus_operations.py index 36b72ea14e57..c67d704686a6 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,153 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } -class AvailableSkusOperations(object): - """AvailableSkusOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeSkuList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,7 +161,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_bandwidth_schedules_operations.py index 3d7a92ff7fdb..dd419ddb2e21 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,268 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class BandwidthSchedulesOperations(object): - """BandwidthSchedulesOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BandwidthSchedulesList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +276,126 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BandwidthSchedule" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BandwidthSchedule"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +404,215 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BandwidthSchedule"] + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +622,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_containers_operations.py index 43552ff41f6d..93d42fefa33a 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,329 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_storage_account_request( + device_name: str, storage_account_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ContainersOperations(object): - """ContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_storage_account( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ContainerList"] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,124 +337,135 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Container" + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Container"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -249,55 +474,149 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Container"] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2020_12_01.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Container or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2020_12_01.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -305,80 +624,75 @@ def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -388,121 +702,116 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -512,81 +821,79 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace def begin_refresh( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_devices_operations.py index ff371ee8fd4a..d4f613c39c86 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,646 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", + ) # 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"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_download_updates_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_generate_certificate_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_extended_information_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_install_updates_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_settings_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_scan_for_updates_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_security_settings_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_update_extended_information_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class DevicesOperations(object): - """DevicesOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_update_summary_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_upload_certificate_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_subscription( - self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,75 +654,90 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,230 +746,325 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } def _create_or_update_initial( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -425,174 +1074,243 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload def update( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDevicePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - def _download_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -602,227 +1320,232 @@ def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } - def begin_download_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_download_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._download_updates_initial( + raw_result = self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace def generate_certificate( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GenerateCertResponse" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: """Generates certificate for activation key. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenerateCertResponse, or the result of cls(response) + :return: GenerateCertResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.GenerateCertResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCertResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.generate_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateCertResponse', pipeline_response) + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate'} # type: ignore + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace def get_extended_information( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - def _install_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -832,168 +1555,170 @@ def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } - def begin_install_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_install_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._install_updates_initial( + raw_result = self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace def get_network_settings( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkSettings" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - def _scan_for_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1003,115 +1728,124 @@ def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def begin_scan_for_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_scan_for_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._scan_for_updates_initial( + raw_result = self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def _create_or_update_security_settings_initial( + def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1121,269 +1855,491 @@ def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload def begin_create_or_update_security_settings( self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2020_12_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2020_12_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_security_settings_initial( + raw_result = self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace def update_extended_information( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDeviceExtendedInfoPatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The patch object. + :param parameters: The patch object. Is either a model type or a IO type. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfoPatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDeviceExtendedInfoPatch') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation'} # type: ignore - def get_update_summary( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateSummary" - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace + def get_update_summary(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload def upload_certificate( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.UploadCertificateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.UploadCertificateResponse" + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_jobs_operations.py index 0f247c2dadde..ceec4b71b497 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class JobsOperations(object): - """JobsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_monitoring_config_operations.py index b7a1149d557f..4efac816af08 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_monitoring_config_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_monitoring_config_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + device_name: str, role_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class MonitoringConfigOperations(object): - """MonitoringConfigOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MonitoringMetricConfigurationList"] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.MonitoringMetricConfiguration"]: """Lists metric configurations in a role. Lists metric configurations in a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 MonitoringMetricConfigurationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfigurationList', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,118 +283,130 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + @distributed_trace def get( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MonitoringMetricConfiguration" + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: """Gets a metric configuration of a role. Gets a metric configuration of a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringMetricConfiguration, or the result of cls(response) + :return: MonitoringMetricConfiguration or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } def _create_or_update_initial( self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - monitoring_metric_configuration, # type: "_models.MonitoringMetricConfiguration" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MonitoringMetricConfiguration"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MonitoringMetricConfiguration"]] + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(monitoring_metric_configuration, 'MonitoringMetricConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -243,129 +415,223 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - monitoring_metric_configuration, # type: "_models.MonitoringMetricConfiguration" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MonitoringMetricConfiguration"] + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: """Creates a new metric configuration or updates an existing one for a role. Creates a new metric configuration or updates an existing one for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param monitoring_metric_configuration: The metric configuration. - :type monitoring_metric_configuration: ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, monitoring_metric_configuration=monitoring_metric_configuration, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) - + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -375,76 +641,76 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """deletes a new metric configuration for a role. deletes a new metric configuration for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_nodes_operations.py index 78229359702b..6fbebb0e31da 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,166 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class NodesOperations(object): - """NodesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NodeList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +174,8 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_operations.py index 90ce016c463a..bdbbbe9cfa94 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") -class Operations(object): - """Operations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataBoxEdge/operations") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +155,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_operations_status_operations.py index f1f15e5aa3c9..52dc13e7cb98 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class OperationsStatusOperations(object): - """OperationsStatusOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_orders_operations.py index 6895a9da9339..d3600d0899ad 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,295 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request(device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class OrdersOperations(object): - """OrdersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_dc_access_code_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OrderList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,112 +303,119 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Order" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } def _create_or_update_initial( - self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Order"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,122 +424,200 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Order"] + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2020_12_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2020_12_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,132 +627,133 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def list_dc_access_code( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DCAccessCode" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace + def list_dc_access_code(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DCAccessCode: """Gets the DCAccess Code. Gets the DCAccess Code. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DCAccessCode, or the result of cls(response) + :return: DCAccessCode or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.DCAccessCode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DCAccessCode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.list_dc_access_code.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DCAccessCode', pipeline_response) + deserialized = self._deserialize("DCAccessCode", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_dc_access_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode'} # type: ignore + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_roles_operations.py index 3d7eaba27c8a..a2006e5a0963 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,267 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class RolesOperations(object): - """RolesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +275,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Role" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Role"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +398,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Role"] + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2020_12_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2020_12_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +604,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_shares_operations.py index d0bb45caa897..dfc9a8983aea 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,301 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_delete_request( + device_name: str, name: str, 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 {}) -class SharesOperations(object): - """SharesOperations operations. + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ShareList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +309,123 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Share" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Share"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +434,209 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Share"] + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2020_12_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2020_12_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,114 +646,110 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -488,76 +759,74 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } - def begin_refresh( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_refresh(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_storage_account_credentials_operations.py index 77dd4662c491..c73763ed4497 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,271 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class StorageAccountCredentialsOperations(object): - """StorageAccountCredentialsOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountCredentialList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,116 +279,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountCredential" + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccountCredential"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -237,127 +409,217 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccountCredential"] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -367,74 +629,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_storage_accounts_operations.py index e62921192cf6..5f2d4a437344 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,269 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, storage_account_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, storage_account_name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, storage_account_name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccount"]: """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +277,130 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccount" + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccount"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +409,221 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccount"] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -371,74 +633,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_triggers_operations.py index 121a94ea9905..e385eb90de24 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,273 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class TriggersOperations(object): - """TriggersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TriggerList"] + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +281,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Trigger" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Trigger"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,127 +404,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Trigger"] + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2020_12_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Trigger or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2020_12_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +610,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_users_operations.py index 774e1ad9db56..e6c94d05464e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/datab/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,115 +6,273 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class UsersOperations(object): - """UsersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_12_01.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserList"] + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='Type eq :code:``' to filter on user type property. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_12_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,116 +281,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_12_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.User"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -240,128 +404,206 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.User"] + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2020_12_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2020_12_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_12_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +613,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-12-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-12-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/__init__.py index e63196b6b98f..daee29a5a3fe 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_configuration.py index 58d4b497e3aa..4f9b87efef95 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_configuration.py @@ -8,18 +8,16 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class DataBoxEdgeManagementClientConfiguration(Configuration): @@ -28,19 +26,18 @@ class DataBoxEdgeManagementClientConfiguration(Configuration): 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any ): - # type: (...) -> None if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -55,9 +52,8 @@ def __init__( def _configure( self, - **kwargs # type: Any + **kwargs: 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) @@ -68,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_data_box_edge_management_client.py index cc262d6f2e12..ee7f237e7ac4 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_data_box_edge_management_client.py @@ -9,21 +9,18 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import DataBoxEdgeManagementClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -43,9 +40,9 @@ class DataBoxEdgeManagementClient(MultiApiClientMixin, _SDKClient): 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :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 @@ -56,7 +53,7 @@ class DataBoxEdgeManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2020-09-01' + DEFAULT_API_VERSION = '2021-02-01' _PROFILE_TAG = "azure.mgmt.databoxedge.DataBoxEdgeManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -68,15 +65,13 @@ class DataBoxEdgeManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] - profile=KnownProfiles.default, # type: KnownProfiles - **kwargs # type: Any + credential: "TokenCredential", + subscription_id: str, + api_version: Optional[str]=None, + base_url: str = "https://management.azure.com", + profile: KnownProfiles=KnownProfiles.default, + **kwargs: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(DataBoxEdgeManagementClient, self).__init__( @@ -98,6 +93,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2020-05-01-preview: :mod:`v2020_05_01_preview.models` * 2020-09-01: :mod:`v2020_09_01.models` * 2020-09-01-preview: :mod:`v2020_09_01_preview.models` + * 2021-02-01: :mod:`v2021_02_01.models` * 2021-02-01-preview: :mod:`v2021_02_01_preview.models` """ if api_version == '2019-03-01': @@ -118,6 +114,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2020-09-01-preview': from .v2020_09_01_preview import models return models + elif api_version == '2021-02-01': + from .v2021_02_01 import models + return models elif api_version == '2021-02-01-preview': from .v2021_02_01_preview import models return models @@ -129,6 +128,7 @@ def addons(self): * 2020-09-01: :class:`AddonsOperations` * 2020-09-01-preview: :class:`AddonsOperations` + * 2021-02-01: :class:`AddonsOperations` * 2021-02-01-preview: :class:`AddonsOperations` """ api_version = self._get_api_version('addons') @@ -136,10 +136,13 @@ def addons(self): from .v2020_09_01.operations import AddonsOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import AddonsOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import AddonsOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import AddonsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'addons'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -152,6 +155,7 @@ def alerts(self): * 2020-05-01-preview: :class:`AlertsOperations` * 2020-09-01: :class:`AlertsOperations` * 2020-09-01-preview: :class:`AlertsOperations` + * 2021-02-01: :class:`AlertsOperations` * 2021-02-01-preview: :class:`AlertsOperations` """ api_version = self._get_api_version('alerts') @@ -167,10 +171,13 @@ def alerts(self): from .v2020_09_01.operations import AlertsOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import AlertsOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import AlertsOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import AlertsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -180,6 +187,7 @@ def available_skus(self): * 2020-05-01-preview: :class:`AvailableSkusOperations` * 2020-09-01: :class:`AvailableSkusOperations` * 2020-09-01-preview: :class:`AvailableSkusOperations` + * 2021-02-01: :class:`AvailableSkusOperations` * 2021-02-01-preview: :class:`AvailableSkusOperations` """ api_version = self._get_api_version('available_skus') @@ -189,10 +197,13 @@ def available_skus(self): from .v2020_09_01.operations import AvailableSkusOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import AvailableSkusOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import AvailableSkusOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import AvailableSkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'available_skus'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -205,6 +216,7 @@ def bandwidth_schedules(self): * 2020-05-01-preview: :class:`BandwidthSchedulesOperations` * 2020-09-01: :class:`BandwidthSchedulesOperations` * 2020-09-01-preview: :class:`BandwidthSchedulesOperations` + * 2021-02-01: :class:`BandwidthSchedulesOperations` * 2021-02-01-preview: :class:`BandwidthSchedulesOperations` """ api_version = self._get_api_version('bandwidth_schedules') @@ -220,10 +232,13 @@ def bandwidth_schedules(self): from .v2020_09_01.operations import BandwidthSchedulesOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import BandwidthSchedulesOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import BandwidthSchedulesOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import BandwidthSchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'bandwidth_schedules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -234,6 +249,7 @@ def containers(self): * 2020-05-01-preview: :class:`ContainersOperations` * 2020-09-01: :class:`ContainersOperations` * 2020-09-01-preview: :class:`ContainersOperations` + * 2021-02-01: :class:`ContainersOperations` * 2021-02-01-preview: :class:`ContainersOperations` """ api_version = self._get_api_version('containers') @@ -245,10 +261,13 @@ def containers(self): from .v2020_09_01.operations import ContainersOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import ContainersOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import ContainersOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import ContainersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'containers'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -261,6 +280,7 @@ def devices(self): * 2020-05-01-preview: :class:`DevicesOperations` * 2020-09-01: :class:`DevicesOperations` * 2020-09-01-preview: :class:`DevicesOperations` + * 2021-02-01: :class:`DevicesOperations` * 2021-02-01-preview: :class:`DevicesOperations` """ api_version = self._get_api_version('devices') @@ -276,10 +296,27 @@ def devices(self): from .v2020_09_01.operations import DevicesOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import DevicesOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import DevicesOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import DevicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'devices'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def diagnostic_settings(self): + """Instance depends on the API version: + + * 2021-02-01: :class:`DiagnosticSettingsOperations` + """ + api_version = self._get_api_version('diagnostic_settings') + if api_version == '2021-02-01': + from .v2021_02_01.operations import DiagnosticSettingsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'diagnostic_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -292,6 +329,7 @@ def jobs(self): * 2020-05-01-preview: :class:`JobsOperations` * 2020-09-01: :class:`JobsOperations` * 2020-09-01-preview: :class:`JobsOperations` + * 2021-02-01: :class:`JobsOperations` * 2021-02-01-preview: :class:`JobsOperations` """ api_version = self._get_api_version('jobs') @@ -307,10 +345,13 @@ def jobs(self): from .v2020_09_01.operations import JobsOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import JobsOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import JobsOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import JobsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'jobs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -319,6 +360,7 @@ def monitoring_config(self): * 2020-09-01: :class:`MonitoringConfigOperations` * 2020-09-01-preview: :class:`MonitoringConfigOperations` + * 2021-02-01: :class:`MonitoringConfigOperations` * 2021-02-01-preview: :class:`MonitoringConfigOperations` """ api_version = self._get_api_version('monitoring_config') @@ -326,10 +368,13 @@ def monitoring_config(self): from .v2020_09_01.operations import MonitoringConfigOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import MonitoringConfigOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import MonitoringConfigOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import MonitoringConfigOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'monitoring_config'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -341,6 +386,7 @@ def nodes(self): * 2020-05-01-preview: :class:`NodesOperations` * 2020-09-01: :class:`NodesOperations` * 2020-09-01-preview: :class:`NodesOperations` + * 2021-02-01: :class:`NodesOperations` * 2021-02-01-preview: :class:`NodesOperations` """ api_version = self._get_api_version('nodes') @@ -354,10 +400,13 @@ def nodes(self): from .v2020_09_01.operations import NodesOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import NodesOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import NodesOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import NodesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'nodes'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -370,6 +419,7 @@ def operations(self): * 2020-05-01-preview: :class:`Operations` * 2020-09-01: :class:`Operations` * 2020-09-01-preview: :class:`Operations` + * 2021-02-01: :class:`Operations` * 2021-02-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') @@ -385,10 +435,13 @@ def operations(self): from .v2020_09_01.operations import Operations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import Operations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import Operations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -401,6 +454,7 @@ def operations_status(self): * 2020-05-01-preview: :class:`OperationsStatusOperations` * 2020-09-01: :class:`OperationsStatusOperations` * 2020-09-01-preview: :class:`OperationsStatusOperations` + * 2021-02-01: :class:`OperationsStatusOperations` * 2021-02-01-preview: :class:`OperationsStatusOperations` """ api_version = self._get_api_version('operations_status') @@ -416,10 +470,13 @@ def operations_status(self): from .v2020_09_01.operations import OperationsStatusOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import OperationsStatusOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import OperationsStatusOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import OperationsStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations_status'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -432,6 +489,7 @@ def orders(self): * 2020-05-01-preview: :class:`OrdersOperations` * 2020-09-01: :class:`OrdersOperations` * 2020-09-01-preview: :class:`OrdersOperations` + * 2021-02-01: :class:`OrdersOperations` * 2021-02-01-preview: :class:`OrdersOperations` """ api_version = self._get_api_version('orders') @@ -447,10 +505,13 @@ def orders(self): from .v2020_09_01.operations import OrdersOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import OrdersOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import OrdersOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import OrdersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'orders'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -463,6 +524,7 @@ def roles(self): * 2020-05-01-preview: :class:`RolesOperations` * 2020-09-01: :class:`RolesOperations` * 2020-09-01-preview: :class:`RolesOperations` + * 2021-02-01: :class:`RolesOperations` * 2021-02-01-preview: :class:`RolesOperations` """ api_version = self._get_api_version('roles') @@ -478,10 +540,13 @@ def roles(self): from .v2020_09_01.operations import RolesOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import RolesOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import RolesOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import RolesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'roles'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -494,6 +559,7 @@ def shares(self): * 2020-05-01-preview: :class:`SharesOperations` * 2020-09-01: :class:`SharesOperations` * 2020-09-01-preview: :class:`SharesOperations` + * 2021-02-01: :class:`SharesOperations` * 2021-02-01-preview: :class:`SharesOperations` """ api_version = self._get_api_version('shares') @@ -509,10 +575,13 @@ def shares(self): from .v2020_09_01.operations import SharesOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import SharesOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import SharesOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import SharesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'shares'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -529,6 +598,7 @@ def skus(self): from .v2020_05_01_preview.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -541,6 +611,7 @@ def storage_account_credentials(self): * 2020-05-01-preview: :class:`StorageAccountCredentialsOperations` * 2020-09-01: :class:`StorageAccountCredentialsOperations` * 2020-09-01-preview: :class:`StorageAccountCredentialsOperations` + * 2021-02-01: :class:`StorageAccountCredentialsOperations` * 2021-02-01-preview: :class:`StorageAccountCredentialsOperations` """ api_version = self._get_api_version('storage_account_credentials') @@ -556,10 +627,13 @@ def storage_account_credentials(self): from .v2020_09_01.operations import StorageAccountCredentialsOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import StorageAccountCredentialsOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import StorageAccountCredentialsOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import StorageAccountCredentialsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_account_credentials'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -570,6 +644,7 @@ def storage_accounts(self): * 2020-05-01-preview: :class:`StorageAccountsOperations` * 2020-09-01: :class:`StorageAccountsOperations` * 2020-09-01-preview: :class:`StorageAccountsOperations` + * 2021-02-01: :class:`StorageAccountsOperations` * 2021-02-01-preview: :class:`StorageAccountsOperations` """ api_version = self._get_api_version('storage_accounts') @@ -581,10 +656,27 @@ def storage_accounts(self): from .v2020_09_01.operations import StorageAccountsOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import StorageAccountsOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import StorageAccountsOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import StorageAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_accounts'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def support_packages(self): + """Instance depends on the API version: + + * 2021-02-01: :class:`SupportPackagesOperations` + """ + api_version = self._get_api_version('support_packages') + if api_version == '2021-02-01': + from .v2021_02_01.operations import SupportPackagesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'support_packages'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -597,6 +689,7 @@ def triggers(self): * 2020-05-01-preview: :class:`TriggersOperations` * 2020-09-01: :class:`TriggersOperations` * 2020-09-01-preview: :class:`TriggersOperations` + * 2021-02-01: :class:`TriggersOperations` * 2021-02-01-preview: :class:`TriggersOperations` """ api_version = self._get_api_version('triggers') @@ -612,10 +705,13 @@ def triggers(self): from .v2020_09_01.operations import TriggersOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import TriggersOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import TriggersOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import TriggersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'triggers'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -628,6 +724,7 @@ def users(self): * 2020-05-01-preview: :class:`UsersOperations` * 2020-09-01: :class:`UsersOperations` * 2020-09-01-preview: :class:`UsersOperations` + * 2021-02-01: :class:`UsersOperations` * 2021-02-01-preview: :class:`UsersOperations` """ api_version = self._get_api_version('users') @@ -643,10 +740,13 @@ def users(self): from .v2020_09_01.operations import UsersOperations as OperationClass elif api_version == '2020-09-01-preview': from .v2020_09_01_preview.operations import UsersOperations as OperationClass + elif api_version == '2021-02-01': + from .v2021_02_01.operations import UsersOperations as OperationClass elif api_version == '2021-02-01-preview': from .v2021_02_01_preview.operations import UsersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'users'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_serialization.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_serialization.py new file mode 100644 index 000000000000..2c170e28dbca --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/_serialization.py @@ -0,0 +1,1967 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import Optional, Union, AnyStr, IO, Mapping + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from typing import Dict, Any, cast + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str + unicode_str = str + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset # type: ignore +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map # type: ignore + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/aio/_configuration.py index 38cf64f9ae5c..e6ce727df88f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/aio/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/aio/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -26,9 +26,9 @@ class DataBoxEdgeManagementClientConfiguration(Configuration): 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str """ @@ -36,7 +36,7 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - **kwargs # type: Any + **kwargs: Any ) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/aio/_data_box_edge_management_client.py index b06c547cfb2e..4aa3a75760cc 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/aio/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/aio/_data_box_edge_management_client.py @@ -11,12 +11,11 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer +from .._serialization import Deserializer, Serializer from ._configuration import DataBoxEdgeManagementClientConfiguration if TYPE_CHECKING: @@ -41,9 +40,9 @@ class DataBoxEdgeManagementClient(MultiApiClientMixin, _SDKClient): 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :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 @@ -54,7 +53,7 @@ class DataBoxEdgeManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2020-09-01' + DEFAULT_API_VERSION = '2021-02-01' _PROFILE_TAG = "azure.mgmt.databoxedge.DataBoxEdgeManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -69,12 +68,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, - **kwargs # type: Any + **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(DataBoxEdgeManagementClient, self).__init__( @@ -96,6 +93,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2020-05-01-preview: :mod:`v2020_05_01_preview.models` * 2020-09-01: :mod:`v2020_09_01.models` * 2020-09-01-preview: :mod:`v2020_09_01_preview.models` + * 2021-02-01: :mod:`v2021_02_01.models` * 2021-02-01-preview: :mod:`v2021_02_01_preview.models` """ if api_version == '2019-03-01': @@ -116,6 +114,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview import models return models + elif api_version == '2021-02-01': + from ..v2021_02_01 import models + return models elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview import models return models @@ -127,6 +128,7 @@ def addons(self): * 2020-09-01: :class:`AddonsOperations` * 2020-09-01-preview: :class:`AddonsOperations` + * 2021-02-01: :class:`AddonsOperations` * 2021-02-01-preview: :class:`AddonsOperations` """ api_version = self._get_api_version('addons') @@ -134,10 +136,13 @@ def addons(self): from ..v2020_09_01.aio.operations import AddonsOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import AddonsOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import AddonsOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import AddonsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'addons'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -150,6 +155,7 @@ def alerts(self): * 2020-05-01-preview: :class:`AlertsOperations` * 2020-09-01: :class:`AlertsOperations` * 2020-09-01-preview: :class:`AlertsOperations` + * 2021-02-01: :class:`AlertsOperations` * 2021-02-01-preview: :class:`AlertsOperations` """ api_version = self._get_api_version('alerts') @@ -165,10 +171,13 @@ def alerts(self): from ..v2020_09_01.aio.operations import AlertsOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import AlertsOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import AlertsOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import AlertsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -178,6 +187,7 @@ def available_skus(self): * 2020-05-01-preview: :class:`AvailableSkusOperations` * 2020-09-01: :class:`AvailableSkusOperations` * 2020-09-01-preview: :class:`AvailableSkusOperations` + * 2021-02-01: :class:`AvailableSkusOperations` * 2021-02-01-preview: :class:`AvailableSkusOperations` """ api_version = self._get_api_version('available_skus') @@ -187,10 +197,13 @@ def available_skus(self): from ..v2020_09_01.aio.operations import AvailableSkusOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import AvailableSkusOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import AvailableSkusOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import AvailableSkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'available_skus'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -203,6 +216,7 @@ def bandwidth_schedules(self): * 2020-05-01-preview: :class:`BandwidthSchedulesOperations` * 2020-09-01: :class:`BandwidthSchedulesOperations` * 2020-09-01-preview: :class:`BandwidthSchedulesOperations` + * 2021-02-01: :class:`BandwidthSchedulesOperations` * 2021-02-01-preview: :class:`BandwidthSchedulesOperations` """ api_version = self._get_api_version('bandwidth_schedules') @@ -218,10 +232,13 @@ def bandwidth_schedules(self): from ..v2020_09_01.aio.operations import BandwidthSchedulesOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import BandwidthSchedulesOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import BandwidthSchedulesOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import BandwidthSchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'bandwidth_schedules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -232,6 +249,7 @@ def containers(self): * 2020-05-01-preview: :class:`ContainersOperations` * 2020-09-01: :class:`ContainersOperations` * 2020-09-01-preview: :class:`ContainersOperations` + * 2021-02-01: :class:`ContainersOperations` * 2021-02-01-preview: :class:`ContainersOperations` """ api_version = self._get_api_version('containers') @@ -243,10 +261,13 @@ def containers(self): from ..v2020_09_01.aio.operations import ContainersOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import ContainersOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import ContainersOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import ContainersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'containers'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -259,6 +280,7 @@ def devices(self): * 2020-05-01-preview: :class:`DevicesOperations` * 2020-09-01: :class:`DevicesOperations` * 2020-09-01-preview: :class:`DevicesOperations` + * 2021-02-01: :class:`DevicesOperations` * 2021-02-01-preview: :class:`DevicesOperations` """ api_version = self._get_api_version('devices') @@ -274,10 +296,27 @@ def devices(self): from ..v2020_09_01.aio.operations import DevicesOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import DevicesOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import DevicesOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import DevicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'devices'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def diagnostic_settings(self): + """Instance depends on the API version: + + * 2021-02-01: :class:`DiagnosticSettingsOperations` + """ + api_version = self._get_api_version('diagnostic_settings') + if api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import DiagnosticSettingsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'diagnostic_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -290,6 +329,7 @@ def jobs(self): * 2020-05-01-preview: :class:`JobsOperations` * 2020-09-01: :class:`JobsOperations` * 2020-09-01-preview: :class:`JobsOperations` + * 2021-02-01: :class:`JobsOperations` * 2021-02-01-preview: :class:`JobsOperations` """ api_version = self._get_api_version('jobs') @@ -305,10 +345,13 @@ def jobs(self): from ..v2020_09_01.aio.operations import JobsOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import JobsOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import JobsOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import JobsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'jobs'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -317,6 +360,7 @@ def monitoring_config(self): * 2020-09-01: :class:`MonitoringConfigOperations` * 2020-09-01-preview: :class:`MonitoringConfigOperations` + * 2021-02-01: :class:`MonitoringConfigOperations` * 2021-02-01-preview: :class:`MonitoringConfigOperations` """ api_version = self._get_api_version('monitoring_config') @@ -324,10 +368,13 @@ def monitoring_config(self): from ..v2020_09_01.aio.operations import MonitoringConfigOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import MonitoringConfigOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import MonitoringConfigOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import MonitoringConfigOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'monitoring_config'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -339,6 +386,7 @@ def nodes(self): * 2020-05-01-preview: :class:`NodesOperations` * 2020-09-01: :class:`NodesOperations` * 2020-09-01-preview: :class:`NodesOperations` + * 2021-02-01: :class:`NodesOperations` * 2021-02-01-preview: :class:`NodesOperations` """ api_version = self._get_api_version('nodes') @@ -352,10 +400,13 @@ def nodes(self): from ..v2020_09_01.aio.operations import NodesOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import NodesOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import NodesOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import NodesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'nodes'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -368,6 +419,7 @@ def operations(self): * 2020-05-01-preview: :class:`Operations` * 2020-09-01: :class:`Operations` * 2020-09-01-preview: :class:`Operations` + * 2021-02-01: :class:`Operations` * 2021-02-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') @@ -383,10 +435,13 @@ def operations(self): from ..v2020_09_01.aio.operations import Operations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import Operations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import Operations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -399,6 +454,7 @@ def operations_status(self): * 2020-05-01-preview: :class:`OperationsStatusOperations` * 2020-09-01: :class:`OperationsStatusOperations` * 2020-09-01-preview: :class:`OperationsStatusOperations` + * 2021-02-01: :class:`OperationsStatusOperations` * 2021-02-01-preview: :class:`OperationsStatusOperations` """ api_version = self._get_api_version('operations_status') @@ -414,10 +470,13 @@ def operations_status(self): from ..v2020_09_01.aio.operations import OperationsStatusOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import OperationsStatusOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import OperationsStatusOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import OperationsStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations_status'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -430,6 +489,7 @@ def orders(self): * 2020-05-01-preview: :class:`OrdersOperations` * 2020-09-01: :class:`OrdersOperations` * 2020-09-01-preview: :class:`OrdersOperations` + * 2021-02-01: :class:`OrdersOperations` * 2021-02-01-preview: :class:`OrdersOperations` """ api_version = self._get_api_version('orders') @@ -445,10 +505,13 @@ def orders(self): from ..v2020_09_01.aio.operations import OrdersOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import OrdersOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import OrdersOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import OrdersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'orders'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -461,6 +524,7 @@ def roles(self): * 2020-05-01-preview: :class:`RolesOperations` * 2020-09-01: :class:`RolesOperations` * 2020-09-01-preview: :class:`RolesOperations` + * 2021-02-01: :class:`RolesOperations` * 2021-02-01-preview: :class:`RolesOperations` """ api_version = self._get_api_version('roles') @@ -476,10 +540,13 @@ def roles(self): from ..v2020_09_01.aio.operations import RolesOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import RolesOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import RolesOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import RolesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'roles'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -492,6 +559,7 @@ def shares(self): * 2020-05-01-preview: :class:`SharesOperations` * 2020-09-01: :class:`SharesOperations` * 2020-09-01-preview: :class:`SharesOperations` + * 2021-02-01: :class:`SharesOperations` * 2021-02-01-preview: :class:`SharesOperations` """ api_version = self._get_api_version('shares') @@ -507,10 +575,13 @@ def shares(self): from ..v2020_09_01.aio.operations import SharesOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import SharesOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import SharesOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import SharesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'shares'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -527,6 +598,7 @@ def skus(self): from ..v2020_05_01_preview.aio.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -539,6 +611,7 @@ def storage_account_credentials(self): * 2020-05-01-preview: :class:`StorageAccountCredentialsOperations` * 2020-09-01: :class:`StorageAccountCredentialsOperations` * 2020-09-01-preview: :class:`StorageAccountCredentialsOperations` + * 2021-02-01: :class:`StorageAccountCredentialsOperations` * 2021-02-01-preview: :class:`StorageAccountCredentialsOperations` """ api_version = self._get_api_version('storage_account_credentials') @@ -554,10 +627,13 @@ def storage_account_credentials(self): from ..v2020_09_01.aio.operations import StorageAccountCredentialsOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import StorageAccountCredentialsOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import StorageAccountCredentialsOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import StorageAccountCredentialsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_account_credentials'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -568,6 +644,7 @@ def storage_accounts(self): * 2020-05-01-preview: :class:`StorageAccountsOperations` * 2020-09-01: :class:`StorageAccountsOperations` * 2020-09-01-preview: :class:`StorageAccountsOperations` + * 2021-02-01: :class:`StorageAccountsOperations` * 2021-02-01-preview: :class:`StorageAccountsOperations` """ api_version = self._get_api_version('storage_accounts') @@ -579,10 +656,27 @@ def storage_accounts(self): from ..v2020_09_01.aio.operations import StorageAccountsOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import StorageAccountsOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import StorageAccountsOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import StorageAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_accounts'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def support_packages(self): + """Instance depends on the API version: + + * 2021-02-01: :class:`SupportPackagesOperations` + """ + api_version = self._get_api_version('support_packages') + if api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import SupportPackagesOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'support_packages'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -595,6 +689,7 @@ def triggers(self): * 2020-05-01-preview: :class:`TriggersOperations` * 2020-09-01: :class:`TriggersOperations` * 2020-09-01-preview: :class:`TriggersOperations` + * 2021-02-01: :class:`TriggersOperations` * 2021-02-01-preview: :class:`TriggersOperations` """ api_version = self._get_api_version('triggers') @@ -610,10 +705,13 @@ def triggers(self): from ..v2020_09_01.aio.operations import TriggersOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import TriggersOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import TriggersOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import TriggersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'triggers'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -626,6 +724,7 @@ def users(self): * 2020-05-01-preview: :class:`UsersOperations` * 2020-09-01: :class:`UsersOperations` * 2020-09-01-preview: :class:`UsersOperations` + * 2021-02-01: :class:`UsersOperations` * 2021-02-01-preview: :class:`UsersOperations` """ api_version = self._get_api_version('users') @@ -641,10 +740,13 @@ def users(self): from ..v2020_09_01.aio.operations import UsersOperations as OperationClass elif api_version == '2020-09-01-preview': from ..v2020_09_01_preview.aio.operations import UsersOperations as OperationClass + elif api_version == '2021-02-01': + from ..v2021_02_01.aio.operations import UsersOperations as OperationClass elif api_version == '2021-02-01-preview': from ..v2021_02_01_preview.aio.operations import UsersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'users'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) async def close(self): diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/models.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/models.py index 04574f8c176c..f63363e712e4 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/models.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/models.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- from .v2019_08_01.models import * -from .v2020_09_01.models import * +from .v2021_02_01.models import * diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/__init__.py index e63196b6b98f..d2bcf6a47896 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/__init__.py @@ -7,10 +7,20 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_configuration.py index 96175fc00331..b37be176840f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_configuration.py @@ -6,65 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", "2019-03-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-03-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_data_box_edge_management_client.py index 03360a537bb9..b165c670fa29 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_data_box_edge_management_client.py @@ -6,35 +6,36 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AlertsOperations, + BandwidthSchedulesOperations, + DevicesOperations, + JobsOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from . import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations @@ -44,11 +45,13 @@ class DataBoxEdgeManagementClient(object): :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2019_03_01.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2019_03_01.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2019_03_01.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2019_03_01.operations.JobsOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2019_03_01.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2019_03_01.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2019_03_01.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -56,89 +59,88 @@ class DataBoxEdgeManagementClient(object): :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2019_03_01.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2019_03_01.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2019_03_01.operations.StorageAccountCredentialsOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2019_03_01.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2019_03_01.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._client, self._config, self._serialize, self._deserialize + ) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None + + 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) -> None: self._client.close() - def __enter__(self): - # type: () -> DataBoxEdgeManagementClient + def __enter__(self) -> "DataBoxEdgeManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_metadata.json b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_metadata.json index 589c36de0e28..5e99cc4f16b9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_metadata.json +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_metadata.json @@ -5,25 +5,25 @@ "name": "DataBoxEdgeManagementClient", "filename": "_data_box_edge_management_client", "description": "The DataBoxEdge Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription ID.", + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription ID.", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=None, # type: Optional[str]", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -111,4 +110,4 @@ "triggers": "TriggersOperations", "users": "UsersOperations" } -} \ No newline at end of file +} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_vendor.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_version.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/__init__.py index c33d46ee91d8..fcb8775eaa10 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_configuration.py index 72a7ebb67c7b..895a4ca23feb 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_configuration.py @@ -6,61 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", "2019-03-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-03-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_data_box_edge_management_client.py index 02a2f028deb6..473c2d2cd3da 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_data_box_edge_management_client.py @@ -6,33 +6,36 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AlertsOperations, + BandwidthSchedulesOperations, + DevicesOperations, + JobsOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .. import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations @@ -42,11 +45,13 @@ class DataBoxEdgeManagementClient(object): :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2019_03_01.aio.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2019_03_01.aio.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2019_03_01.aio.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2019_03_01.aio.operations.JobsOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2019_03_01.aio.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2019_03_01.aio.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2019_03_01.aio.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -54,77 +59,81 @@ class DataBoxEdgeManagementClient(object): :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2019_03_01.aio.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2019_03_01.aio.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2019_03_01.aio.operations.StorageAccountCredentialsOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2019_03_01.aio.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2019_03_01.aio.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/__init__.py index f1ff40408d10..49f127f3253c 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/__init__.py @@ -19,17 +19,23 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_alerts_operations.py index 9b4a8bd1eee8..de66519adc09 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._alerts_operations import build_get_request, build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AlertsOperations: - """AlertsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AlertList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: """Gets all the alerts for a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,71 +142,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Alert": + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_bandwidth_schedules_operations.py index daeb130f0fa5..ee728b983209 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._bandwidth_schedules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BandwidthSchedulesOperations: - """BandwidthSchedulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.BandwidthSchedulesList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.BandwidthSchedule": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> Optional["_models.BandwidthSchedule"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +279,215 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> AsyncLROPoller["_models.BandwidthSchedule"]: + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +497,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_devices_operations.py index 8d94f947e8d9..f859f8627671 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._devices_operations import ( + build_create_or_update_request, + build_create_or_update_security_settings_request, + build_delete_request, + build_download_updates_request, + build_get_extended_information_request, + build_get_network_settings_request, + build_get_request, + build_get_update_summary_request, + build_install_updates_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_scan_for_updates_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations: - """DevicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_subscription( - self, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the data box edge/gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,74 +158,90 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the data box edge/gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,226 +250,325 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDevice": + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } async def _create_or_update_initial( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> "_models.DataBoxEdgeDevice": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> AsyncLROPoller["_models.DataBoxEdgeDevice"]: + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -415,171 +578,243 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload async def update( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDevicePatch", - **kwargs - ) -> "_models.DataBoxEdgeDevice": + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - async def _download_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -589,165 +824,172 @@ async def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def begin_download_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Downloads the updates on a data box edge/gateway device. Downloads the updates on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._download_updates_initial( + raw_result = await self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace_async async def get_extended_information( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - async def _install_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + async def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -757,165 +999,172 @@ async def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def begin_install_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Installs the updates on the data box edge/gateway device. Installs the updates on the data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._install_updates_initial( + raw_result = await self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def get_network_settings( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.NetworkSettings": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - async def _scan_for_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + async def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -925,113 +1174,126 @@ async def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + @distributed_trace_async async def begin_scan_for_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Scans for updates on a data box edge/gateway device. Scans for updates on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._scan_for_updates_initial( + raw_result = await self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _create_or_update_security_settings_initial( + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + + async def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1041,199 +1303,355 @@ async def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload async def begin_create_or_update_security_settings( self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the security settings on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2019_03_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a data box edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a data box edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2019_03_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_security_settings_initial( + raw_result = await self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @distributed_trace_async async def get_update_summary( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.UpdateSummary": - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload async def upload_certificate( self, device_name: str, resource_group_name: str, - parameters: "_models.UploadCertificateRequest", - **kwargs - ) -> "_models.UploadCertificateResponse": + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_jobs_operations.py index 235b4f5cd3cf..5c0d5ed5d4b0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class JobsOperations: - """JobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a data box edge/gateway device. Gets the details of a specified job on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_operations.py index 196ad6bf122d..106461df749b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,126 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.OperationsList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +134,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_operations_status_operations.py index 4eb25dfba79d..dc4e04c618d3 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations_status_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsStatusOperations: - """OperationsStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a data box edge/gateway device. Gets the details of a specified job on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_orders_operations.py index 0fe065e6e1bf..92da8476d404 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._orders_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OrdersOperations: - """OrdersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.OrderList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Order"]: """Lists all the orders related to a data box edge/gateway device. Lists all the orders related to a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,110 +151,119 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Order": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } async def _create_or_update_initial( - self, - device_name: str, - resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> Optional["_models.Order"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -226,120 +272,200 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> AsyncLROPoller["_models.Order"]: + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2019_03_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2019_03_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -349,70 +475,71 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_roles_operations.py index 0ba335a802c4..2de5bf84cf8d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._roles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RolesOperations: - """RolesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.RoleList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Role"]: """Lists all the roles configured in a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Role": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> Optional["_models.Role"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +272,203 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> AsyncLROPoller["_models.Role"]: + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2019_03_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2019_03_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +478,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the role on the data box edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_shares_operations.py index 01dbe891f708..372147634742 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._shares_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SharesOperations: - """SharesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ShareList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Share"]: """Lists all the shares in a data box edge/gateway device. Lists all the shares in a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +152,123 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Share": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> Optional["_models.Share"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +277,209 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> AsyncLROPoller["_models.Share"]: + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2019_03_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2019_03_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,112 +489,112 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the share on the data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -477,75 +604,76 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_storage_account_credentials_operations.py index df213b29b49d..3d4d7ab00756 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_account_credentials_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountCredentialsOperations: - """StorageAccountCredentialsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountCredentialList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a data box edge/gateway device. Gets all the storage account credentials in a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,114 +152,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccountCredential": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> Optional["_models.StorageAccountCredential"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -230,125 +282,217 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccountCredential"]: + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,73 +502,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_triggers_operations.py index 33ecf8aa7a8d..93828b50c3c9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._triggers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TriggersOperations: - """TriggersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.TriggerList"]: + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +153,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Trigger": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> Optional["_models.Trigger"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,125 +276,206 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> AsyncLROPoller["_models.Trigger"]: + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2019_03_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Trigger or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Trigger or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2019_03_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +485,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_users_operations.py index 303c99d24052..4725d7362d18 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/aio/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UsersOperations: - """UsersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.aio.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.UserList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.User"]: """Gets all the users registered on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 UserList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.User": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - user: "_models.User", - **kwargs - ) -> Optional["_models.User"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +272,203 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - user: "_models.User", - **kwargs - ) -> AsyncLROPoller["_models.User"]: + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: """Creates a new user or updates an existing user's information on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2019_03_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a data box edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a data box edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2019_03_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +478,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/__init__.py index d86147179315..569cea6ae852 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/__init__.py @@ -6,275 +6,212 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARMBaseModel - from ._models_py3 import Address - from ._models_py3 import Alert - from ._models_py3 import AlertErrorDetails - from ._models_py3 import AlertList - from ._models_py3 import AsymmetricEncryptedSecret - from ._models_py3 import Authentication - from ._models_py3 import AzureContainerInfo - from ._models_py3 import BandwidthSchedule - from ._models_py3 import BandwidthSchedulesList - from ._models_py3 import ClientAccessRight - from ._models_py3 import CloudErrorBody - from ._models_py3 import ContactDetails - from ._models_py3 import DataBoxEdgeDevice - from ._models_py3 import DataBoxEdgeDeviceExtendedInfo - from ._models_py3 import DataBoxEdgeDeviceList - from ._models_py3 import DataBoxEdgeDevicePatch - from ._models_py3 import FileEventTrigger - from ._models_py3 import FileSourceInfo - from ._models_py3 import IoTDeviceInfo - from ._models_py3 import IoTRole - from ._models_py3 import Ipv4Config - from ._models_py3 import Ipv6Config - from ._models_py3 import Job - from ._models_py3 import JobErrorDetails - from ._models_py3 import JobErrorItem - from ._models_py3 import MetricDimensionV1 - from ._models_py3 import MetricSpecificationV1 - from ._models_py3 import MountPointMap - from ._models_py3 import NetworkAdapter - from ._models_py3 import NetworkAdapterPosition - from ._models_py3 import NetworkSettings - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import Order - from ._models_py3 import OrderList - from ._models_py3 import OrderStatus - from ._models_py3 import PeriodicTimerEventTrigger - from ._models_py3 import PeriodicTimerSourceInfo - from ._models_py3 import RefreshDetails - from ._models_py3 import Role - from ._models_py3 import RoleList - from ._models_py3 import RoleSinkInfo - from ._models_py3 import SecuritySettings - from ._models_py3 import ServiceSpecification - from ._models_py3 import Share - from ._models_py3 import ShareAccessRight - from ._models_py3 import ShareList - from ._models_py3 import Sku - from ._models_py3 import StorageAccountCredential - from ._models_py3 import StorageAccountCredentialList - from ._models_py3 import SymmetricKey - from ._models_py3 import TrackingInfo - from ._models_py3 import Trigger - from ._models_py3 import TriggerList - from ._models_py3 import UpdateDownloadProgress - from ._models_py3 import UpdateInstallProgress - from ._models_py3 import UpdateSummary - from ._models_py3 import UploadCertificateRequest - from ._models_py3 import UploadCertificateResponse - from ._models_py3 import User - from ._models_py3 import UserAccessRight - from ._models_py3 import UserList -except (SyntaxError, ImportError): - from ._models import ARMBaseModel # type: ignore - from ._models import Address # type: ignore - from ._models import Alert # type: ignore - from ._models import AlertErrorDetails # type: ignore - from ._models import AlertList # type: ignore - from ._models import AsymmetricEncryptedSecret # type: ignore - from ._models import Authentication # type: ignore - from ._models import AzureContainerInfo # type: ignore - from ._models import BandwidthSchedule # type: ignore - from ._models import BandwidthSchedulesList # type: ignore - from ._models import ClientAccessRight # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import ContactDetails # type: ignore - from ._models import DataBoxEdgeDevice # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfo # type: ignore - from ._models import DataBoxEdgeDeviceList # type: ignore - from ._models import DataBoxEdgeDevicePatch # type: ignore - from ._models import FileEventTrigger # type: ignore - from ._models import FileSourceInfo # type: ignore - from ._models import IoTDeviceInfo # type: ignore - from ._models import IoTRole # type: ignore - from ._models import Ipv4Config # type: ignore - from ._models import Ipv6Config # type: ignore - from ._models import Job # type: ignore - from ._models import JobErrorDetails # type: ignore - from ._models import JobErrorItem # type: ignore - from ._models import MetricDimensionV1 # type: ignore - from ._models import MetricSpecificationV1 # type: ignore - from ._models import MountPointMap # type: ignore - from ._models import NetworkAdapter # type: ignore - from ._models import NetworkAdapterPosition # type: ignore - from ._models import NetworkSettings # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import Order # type: ignore - from ._models import OrderList # type: ignore - from ._models import OrderStatus # type: ignore - from ._models import PeriodicTimerEventTrigger # type: ignore - from ._models import PeriodicTimerSourceInfo # type: ignore - from ._models import RefreshDetails # type: ignore - from ._models import Role # type: ignore - from ._models import RoleList # type: ignore - from ._models import RoleSinkInfo # type: ignore - from ._models import SecuritySettings # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Share # type: ignore - from ._models import ShareAccessRight # type: ignore - from ._models import ShareList # type: ignore - from ._models import Sku # type: ignore - from ._models import StorageAccountCredential # type: ignore - from ._models import StorageAccountCredentialList # type: ignore - from ._models import SymmetricKey # type: ignore - from ._models import TrackingInfo # type: ignore - from ._models import Trigger # type: ignore - from ._models import TriggerList # type: ignore - from ._models import UpdateDownloadProgress # type: ignore - from ._models import UpdateInstallProgress # type: ignore - from ._models import UpdateSummary # type: ignore - from ._models import UploadCertificateRequest # type: ignore - from ._models import UploadCertificateResponse # type: ignore - from ._models import User # type: ignore - from ._models import UserAccessRight # type: ignore - from ._models import UserList # type: ignore +from ._models_py3 import ARMBaseModel +from ._models_py3 import Address +from ._models_py3 import Alert +from ._models_py3 import AlertErrorDetails +from ._models_py3 import AlertList +from ._models_py3 import AsymmetricEncryptedSecret +from ._models_py3 import Authentication +from ._models_py3 import AzureContainerInfo +from ._models_py3 import BandwidthSchedule +from ._models_py3 import BandwidthSchedulesList +from ._models_py3 import ClientAccessRight +from ._models_py3 import CloudErrorBody +from ._models_py3 import ContactDetails +from ._models_py3 import DataBoxEdgeDevice +from ._models_py3 import DataBoxEdgeDeviceExtendedInfo +from ._models_py3 import DataBoxEdgeDeviceList +from ._models_py3 import DataBoxEdgeDevicePatch +from ._models_py3 import FileEventTrigger +from ._models_py3 import FileSourceInfo +from ._models_py3 import IoTDeviceInfo +from ._models_py3 import IoTRole +from ._models_py3 import Ipv4Config +from ._models_py3 import Ipv6Config +from ._models_py3 import Job +from ._models_py3 import JobErrorDetails +from ._models_py3 import JobErrorItem +from ._models_py3 import MetricDimensionV1 +from ._models_py3 import MetricSpecificationV1 +from ._models_py3 import MountPointMap +from ._models_py3 import NetworkAdapter +from ._models_py3 import NetworkAdapterPosition +from ._models_py3 import NetworkSettings +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import Order +from ._models_py3 import OrderList +from ._models_py3 import OrderStatus +from ._models_py3 import PeriodicTimerEventTrigger +from ._models_py3 import PeriodicTimerSourceInfo +from ._models_py3 import RefreshDetails +from ._models_py3 import Role +from ._models_py3 import RoleList +from ._models_py3 import RoleSinkInfo +from ._models_py3 import SecuritySettings +from ._models_py3 import ServiceSpecification +from ._models_py3 import Share +from ._models_py3 import ShareAccessRight +from ._models_py3 import ShareList +from ._models_py3 import Sku +from ._models_py3 import StorageAccountCredential +from ._models_py3 import StorageAccountCredentialList +from ._models_py3 import SymmetricKey +from ._models_py3 import TrackingInfo +from ._models_py3 import Trigger +from ._models_py3 import TriggerList +from ._models_py3 import UpdateDownloadProgress +from ._models_py3 import UpdateInstallProgress +from ._models_py3 import UpdateSummary +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UploadCertificateResponse +from ._models_py3 import User +from ._models_py3 import UserAccessRight +from ._models_py3 import UserList -from ._data_box_edge_management_client_enums import ( - AccountType, - AlertSeverity, - AuthenticationType, - AzureContainerDataFormat, - ClientPermissionType, - DataBoxEdgeDeviceStatus, - DataPolicy, - DayOfWeek, - DeviceType, - DownloadPhase, - EncryptionAlgorithm, - InstallRebootBehavior, - JobStatus, - JobType, - MetricAggregationType, - MetricCategory, - MetricUnit, - MonitoringStatus, - NetworkAdapterDHCPStatus, - NetworkAdapterRDMAStatus, - NetworkAdapterStatus, - NetworkGroup, - OrderState, - PlatformType, - RoleStatus, - RoleTypes, - SSLStatus, - ShareAccessProtocol, - ShareAccessType, - ShareStatus, - SkuName, - SkuTier, - TimeGrain, - TriggerEventType, - UpdateOperation, - UpdateOperationStage, -) +from ._data_box_edge_management_client_enums import AccountType +from ._data_box_edge_management_client_enums import AlertSeverity +from ._data_box_edge_management_client_enums import AuthenticationType +from ._data_box_edge_management_client_enums import AzureContainerDataFormat +from ._data_box_edge_management_client_enums import ClientPermissionType +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceStatus +from ._data_box_edge_management_client_enums import DataPolicy +from ._data_box_edge_management_client_enums import DayOfWeek +from ._data_box_edge_management_client_enums import DeviceType +from ._data_box_edge_management_client_enums import DownloadPhase +from ._data_box_edge_management_client_enums import EncryptionAlgorithm +from ._data_box_edge_management_client_enums import InstallRebootBehavior +from ._data_box_edge_management_client_enums import JobStatus +from ._data_box_edge_management_client_enums import JobType +from ._data_box_edge_management_client_enums import MetricAggregationType +from ._data_box_edge_management_client_enums import MetricCategory +from ._data_box_edge_management_client_enums import MetricUnit +from ._data_box_edge_management_client_enums import MonitoringStatus +from ._data_box_edge_management_client_enums import NetworkAdapterDHCPStatus +from ._data_box_edge_management_client_enums import NetworkAdapterRDMAStatus +from ._data_box_edge_management_client_enums import NetworkAdapterStatus +from ._data_box_edge_management_client_enums import NetworkGroup +from ._data_box_edge_management_client_enums import OrderState +from ._data_box_edge_management_client_enums import PlatformType +from ._data_box_edge_management_client_enums import RoleStatus +from ._data_box_edge_management_client_enums import RoleTypes +from ._data_box_edge_management_client_enums import SSLStatus +from ._data_box_edge_management_client_enums import ShareAccessProtocol +from ._data_box_edge_management_client_enums import ShareAccessType +from ._data_box_edge_management_client_enums import ShareStatus +from ._data_box_edge_management_client_enums import SkuName +from ._data_box_edge_management_client_enums import SkuTier +from ._data_box_edge_management_client_enums import TimeGrain +from ._data_box_edge_management_client_enums import TriggerEventType +from ._data_box_edge_management_client_enums import UpdateOperation +from ._data_box_edge_management_client_enums import UpdateOperationStage +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ARMBaseModel', - 'Address', - 'Alert', - 'AlertErrorDetails', - 'AlertList', - 'AsymmetricEncryptedSecret', - 'Authentication', - 'AzureContainerInfo', - 'BandwidthSchedule', - 'BandwidthSchedulesList', - 'ClientAccessRight', - 'CloudErrorBody', - 'ContactDetails', - 'DataBoxEdgeDevice', - 'DataBoxEdgeDeviceExtendedInfo', - 'DataBoxEdgeDeviceList', - 'DataBoxEdgeDevicePatch', - 'FileEventTrigger', - 'FileSourceInfo', - 'IoTDeviceInfo', - 'IoTRole', - 'Ipv4Config', - 'Ipv6Config', - 'Job', - 'JobErrorDetails', - 'JobErrorItem', - 'MetricDimensionV1', - 'MetricSpecificationV1', - 'MountPointMap', - 'NetworkAdapter', - 'NetworkAdapterPosition', - 'NetworkSettings', - 'Operation', - 'OperationDisplay', - 'OperationsList', - 'Order', - 'OrderList', - 'OrderStatus', - 'PeriodicTimerEventTrigger', - 'PeriodicTimerSourceInfo', - 'RefreshDetails', - 'Role', - 'RoleList', - 'RoleSinkInfo', - 'SecuritySettings', - 'ServiceSpecification', - 'Share', - 'ShareAccessRight', - 'ShareList', - 'Sku', - 'StorageAccountCredential', - 'StorageAccountCredentialList', - 'SymmetricKey', - 'TrackingInfo', - 'Trigger', - 'TriggerList', - 'UpdateDownloadProgress', - 'UpdateInstallProgress', - 'UpdateSummary', - 'UploadCertificateRequest', - 'UploadCertificateResponse', - 'User', - 'UserAccessRight', - 'UserList', - 'AccountType', - 'AlertSeverity', - 'AuthenticationType', - 'AzureContainerDataFormat', - 'ClientPermissionType', - 'DataBoxEdgeDeviceStatus', - 'DataPolicy', - 'DayOfWeek', - 'DeviceType', - 'DownloadPhase', - 'EncryptionAlgorithm', - 'InstallRebootBehavior', - 'JobStatus', - 'JobType', - 'MetricAggregationType', - 'MetricCategory', - 'MetricUnit', - 'MonitoringStatus', - 'NetworkAdapterDHCPStatus', - 'NetworkAdapterRDMAStatus', - 'NetworkAdapterStatus', - 'NetworkGroup', - 'OrderState', - 'PlatformType', - 'RoleStatus', - 'RoleTypes', - 'SSLStatus', - 'ShareAccessProtocol', - 'ShareAccessType', - 'ShareStatus', - 'SkuName', - 'SkuTier', - 'TimeGrain', - 'TriggerEventType', - 'UpdateOperation', - 'UpdateOperationStage', + "ARMBaseModel", + "Address", + "Alert", + "AlertErrorDetails", + "AlertList", + "AsymmetricEncryptedSecret", + "Authentication", + "AzureContainerInfo", + "BandwidthSchedule", + "BandwidthSchedulesList", + "ClientAccessRight", + "CloudErrorBody", + "ContactDetails", + "DataBoxEdgeDevice", + "DataBoxEdgeDeviceExtendedInfo", + "DataBoxEdgeDeviceList", + "DataBoxEdgeDevicePatch", + "FileEventTrigger", + "FileSourceInfo", + "IoTDeviceInfo", + "IoTRole", + "Ipv4Config", + "Ipv6Config", + "Job", + "JobErrorDetails", + "JobErrorItem", + "MetricDimensionV1", + "MetricSpecificationV1", + "MountPointMap", + "NetworkAdapter", + "NetworkAdapterPosition", + "NetworkSettings", + "Operation", + "OperationDisplay", + "OperationsList", + "Order", + "OrderList", + "OrderStatus", + "PeriodicTimerEventTrigger", + "PeriodicTimerSourceInfo", + "RefreshDetails", + "Role", + "RoleList", + "RoleSinkInfo", + "SecuritySettings", + "ServiceSpecification", + "Share", + "ShareAccessRight", + "ShareList", + "Sku", + "StorageAccountCredential", + "StorageAccountCredentialList", + "SymmetricKey", + "TrackingInfo", + "Trigger", + "TriggerList", + "UpdateDownloadProgress", + "UpdateInstallProgress", + "UpdateSummary", + "UploadCertificateRequest", + "UploadCertificateResponse", + "User", + "UserAccessRight", + "UserList", + "AccountType", + "AlertSeverity", + "AuthenticationType", + "AzureContainerDataFormat", + "ClientPermissionType", + "DataBoxEdgeDeviceStatus", + "DataPolicy", + "DayOfWeek", + "DeviceType", + "DownloadPhase", + "EncryptionAlgorithm", + "InstallRebootBehavior", + "JobStatus", + "JobType", + "MetricAggregationType", + "MetricCategory", + "MetricUnit", + "MonitoringStatus", + "NetworkAdapterDHCPStatus", + "NetworkAdapterRDMAStatus", + "NetworkAdapterStatus", + "NetworkGroup", + "OrderState", + "PlatformType", + "RoleStatus", + "RoleTypes", + "SSLStatus", + "ShareAccessProtocol", + "ShareAccessType", + "ShareStatus", + "SkuName", + "SkuTier", + "TimeGrain", + "TriggerEventType", + "UpdateOperation", + "UpdateOperationStage", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_data_box_edge_management_client_enums.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_data_box_edge_management_client_enums.py index 03b262f20b0d..61f91185d2ab 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_data_box_edge_management_client_enums.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_data_box_edge_management_client_enums.py @@ -6,67 +6,50 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of storage accessed on the storage account. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of storage accessed on the storage account.""" GENERAL_PURPOSE_STORAGE = "GeneralPurposeStorage" BLOB_STORAGE = "BlobStorage" -class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the alert. - """ + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert.""" INFORMATIONAL = "Informational" WARNING = "Warning" CRITICAL = "Critical" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The authentication type. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication type.""" INVALID = "Invalid" AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" -class AzureContainerDataFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Storage format used for the file represented by the share. - """ + +class AzureContainerDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage format used for the file represented by the share.""" BLOCK_BLOB = "BlockBlob" PAGE_BLOB = "PageBlob" AZURE_FILE = "AzureFile" -class ClientPermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed for the client. - """ + +class ClientPermissionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed for the client.""" NO_ACCESS = "NoAccess" READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the Data Box Edge/Gateway device. - """ + +class DataBoxEdgeDeviceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the Data Box Edge/Gateway device.""" READY_TO_SETUP = "ReadyToSetup" ONLINE = "Online" @@ -75,14 +58,16 @@ class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum DISCONNECTED = "Disconnected" PARTIALLY_DISCONNECTED = "PartiallyDisconnected" -class DataPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Data policy of the share. - """ + +class DataPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data policy of the share.""" CLOUD = "Cloud" LOCAL = "Local" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -92,40 +77,40 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DeviceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the Data Box Edge/Gateway device. - """ + +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the Data Box Edge/Gateway device.""" DATA_BOX_EDGE_DEVICE = "DataBoxEdgeDevice" -class DownloadPhase(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The download phase. - """ + +class DownloadPhase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The download phase.""" UNKNOWN = "Unknown" INITIALIZING = "Initializing" DOWNLOADING = "Downloading" VERIFYING = "Verifying" -class EncryptionAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The algorithm used to encrypt "Value". - """ + +class EncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The algorithm used to encrypt "Value".""" NONE = "None" AES256 = "AES256" RSAES_PKCS1_V1_5 = "RSAES_PKCS1_v_1_5" -class InstallRebootBehavior(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if updates are available and at least one of the updates needs a reboot. - """ + +class InstallRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if updates are available and at least one of the updates needs a reboot.""" NEVER_REBOOTS = "NeverReboots" REQUIRES_REBOOT = "RequiresReboot" REQUEST_REBOOT = "RequestReboot" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the job.""" INVALID = "Invalid" RUNNING = "Running" @@ -135,9 +120,9 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PAUSED = "Paused" SCHEDULED = "Scheduled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" INVALID = "Invalid" SCAN_FOR_UPDATES = "ScanForUpdates" @@ -145,9 +130,9 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INSTALL_UPDATES = "InstallUpdates" REFRESH_SHARE = "RefreshShare" -class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric aggregation type. - """ + +class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric aggregation type.""" NOT_SPECIFIED = "NotSpecified" NONE = "None" @@ -157,16 +142,16 @@ class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) TOTAL = "Total" COUNT = "Count" -class MetricCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric category. - """ + +class MetricCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric category.""" CAPACITY = "Capacity" TRANSACTION = "Transaction" -class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric units. - """ + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric units.""" NOT_SPECIFIED = "NotSpecified" PERCENT = "Percent" @@ -177,45 +162,45 @@ class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BYTES_PER_SECOND = "BytesPerSecond" COUNT_PER_SECOND = "CountPerSecond" -class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current monitoring status of the share. - """ + +class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current monitoring status of the share.""" ENABLED = "Enabled" DISABLED = "Disabled" -class NetworkAdapterDHCPStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter has DHCP enabled. - """ + +class NetworkAdapterDHCPStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter has DHCP enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" -class NetworkAdapterRDMAStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is RDMA capable. - """ + +class NetworkAdapterRDMAStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is RDMA capable.""" INCAPABLE = "Incapable" CAPABLE = "Capable" -class NetworkAdapterStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is valid. - """ + +class NetworkAdapterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is valid.""" INACTIVE = "Inactive" ACTIVE = "Active" -class NetworkGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The network group. - """ + +class NetworkGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network group.""" NONE = "None" NON_RDMA = "NonRDMA" RDMA = "RDMA" -class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the order as per the allowed status types. - """ + +class OrderState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the order as per the allowed status types.""" UNTRACKED = "Untracked" AWAITING_FULFILMENT = "AwaitingFulfilment" @@ -232,70 +217,74 @@ class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SHIPPED_BACK = "ShippedBack" COLLECTED_AT_MICROSOFT = "CollectedAtMicrosoft" -class PlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Host OS supported by the IoT role. - """ + +class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host OS supported by the IoT role.""" WINDOWS = "Windows" LINUX = "Linux" -class RoleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Role status. - """ + +class RoleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Role status.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RoleTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleTypes.""" IOT = "IOT" ASA = "ASA" FUNCTIONS = "Functions" COGNITIVE = "Cognitive" -class ShareAccessProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Access protocol to be used by the share. - """ + +class ShareAccessProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access protocol to be used by the share.""" SMB = "SMB" NFS = "NFS" -class ShareAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed on the share for this user. - """ + +class ShareAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed on the share for this user.""" CHANGE = "Change" READ = "Read" CUSTOM = "Custom" -class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the share. - """ + +class ShareStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the share.""" ONLINE = "Online" OFFLINE = "Offline" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """SKU name. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SKU name.""" GATEWAY = "Gateway" EDGE = "Edge" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier. This is based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" -class SSLStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Signifies whether SSL needs to be enabled or not. - """ + +class SSLStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Signifies whether SSL needs to be enabled or not.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class TimeGrain(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TimeGrain.""" PT1_M = "PT1M" PT5_M = "PT5M" @@ -306,25 +295,25 @@ class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PT12_H = "PT12H" PT1_D = "PT1D" -class TriggerEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Trigger Kind. - """ + +class TriggerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trigger Kind.""" FILE_EVENT = "FileEvent" PERIODIC_TIMER_EVENT = "PeriodicTimerEvent" -class UpdateOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current update operation. - """ + +class UpdateOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current update operation.""" NONE = "None" SCAN = "Scan" DOWNLOAD = "Download" INSTALL = "Install" -class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current stage of the update operation. - """ + +class UpdateOperationStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current stage of the update operation.""" UNKNOWN = "Unknown" INITIAL = "Initial" diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_models.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_models.py deleted file mode 100644 index 721721347494..000000000000 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_models.py +++ /dev/null @@ -1,2752 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class Address(msrest.serialization.Model): - """The shipping address of the customer. - - All required parameters must be populated in order to send to Azure. - - :param address_line1: Required. The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: Required. The postal code. - :type postal_code: str - :param city: Required. The city name. - :type city: str - :param state: Required. The state name. - :type state: str - :param country: Required. The country name. - :type country: str - """ - - _validation = { - 'address_line1': {'required': True}, - 'postal_code': {'required': True}, - 'city': {'required': True}, - 'state': {'required': True}, - 'country': {'required': True}, - } - - _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Address, self).__init__(**kwargs) - self.address_line1 = kwargs['address_line1'] - self.address_line2 = kwargs.get('address_line2', None) - self.address_line3 = kwargs.get('address_line3', None) - self.postal_code = kwargs['postal_code'] - self.city = kwargs['city'] - self.state = kwargs['state'] - self.country = kwargs['country'] - - -class ARMBaseModel(msrest.serialization.Model): - """Represents the base class for all object models. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Alert(ARMBaseModel): - """Alert on the data box edge/gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar title: Alert title. - :vartype title: str - :ivar alert_type: Alert type. - :vartype alert_type: str - :ivar appeared_at_date_time: UTC time when the alert appeared. - :vartype appeared_at_date_time: ~datetime.datetime - :ivar recommendation: Alert recommendation. - :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", - "Critical". - :vartype severity: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AlertSeverity - :ivar error_details: Error details of the alert. - :vartype error_details: ~azure.mgmt.databoxedge.v2019_03_01.models.AlertErrorDetails - :ivar detailed_information: Alert details. - :vartype detailed_information: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) - self.title = None - self.alert_type = None - self.appeared_at_date_time = None - self.recommendation = None - self.severity = None - self.error_details = None - self.detailed_information = None - - -class AlertErrorDetails(msrest.serialization.Model): - """Error details for the alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code. - :vartype error_code: str - :ivar error_message: Error Message. - :vartype error_message: str - :ivar occurrences: Number of occurrences. - :vartype occurrences: int - """ - - _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) - self.error_code = None - self.error_message = None - self.occurrences = None - - -class AlertList(msrest.serialization.Model): - """Collection of alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.Alert] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class AsymmetricEncryptedSecret(msrest.serialization.Model): - """Represent the secrets intended for encryption with asymmetric key pair. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the - value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or - ~azure.mgmt.databoxedge.v2019_03_01.models.EncryptionAlgorithm - """ - - _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) - self.value = kwargs['value'] - self.encryption_cert_thumbprint = kwargs.get('encryption_cert_thumbprint', None) - self.encryption_algorithm = kwargs['encryption_algorithm'] - - -class Authentication(msrest.serialization.Model): - """Authentication mechanism for IoT devices. - - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2019_03_01.models.SymmetricKey - """ - - _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, - } - - def __init__( - self, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) - self.symmetric_key = kwargs.get('symmetric_key', None) - - -class AzureContainerInfo(msrest.serialization.Model): - """Azure container mapping of the endpoint. - - All required parameters must be populated in order to send to Azure. - - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AzureContainerDataFormat - """ - - _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, - } - - _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) - self.storage_account_credential_id = kwargs['storage_account_credential_id'] - self.container_name = kwargs['container_name'] - self.data_format = kwargs['data_format'] - - -class BandwidthSchedule(ARMBaseModel): - """The bandwidth schedule details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2019_03_01.models.DayOfWeek] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) - self.start = kwargs['start'] - self.stop = kwargs['stop'] - self.rate_in_mbps = kwargs['rate_in_mbps'] - self.days = kwargs['days'] - - -class BandwidthSchedulesList(msrest.serialization.Model): - """The collection of bandwidth schedules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of bandwidth schedules. - :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ClientAccessRight(msrest.serialization.Model): - """The mapping between a particular client IP and the type of access client has on the NFS share. - - All required parameters must be populated in order to send to Azure. - - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ClientPermissionType - """ - - _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, - } - - _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) - self.client = kwargs['client'] - self.access_permission = kwargs['access_permission'] - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2019_03_01.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class ContactDetails(msrest.serialization.Model): - """Contains all the contact details of the customer. - - All required parameters must be populated in order to send to Azure. - - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] - """ - - _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) - self.contact_person = kwargs['contact_person'] - self.company_name = kwargs['company_name'] - self.phone = kwargs['phone'] - self.email_list = kwargs['email_list'] - - -class DataBoxEdgeDevice(ARMBaseModel): - """The Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure - geographical region (for example, West US, East US, or Southeast Asia). The geographical region - of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2019_03_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected". - :type data_box_edge_device_status: str or - ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDeviceStatus - :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. - :vartype serial_number: str - :param description: The Description of the Data Box Edge/Gateway device. - :type description: str - :param model_description: The description of the Data Box Edge/Gateway device model. - :type model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". - :vartype device_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.DeviceType - :param friendly_name: The Data Box Edge/Gateway device name. - :type friendly_name: str - :ivar culture: The Data Box Edge/Gateway device culture. - :vartype culture: str - :ivar device_model: The Data Box Edge/Gateway device model. - :vartype device_model: str - :ivar device_software_version: The Data Box Edge/Gateway device software version. - :vartype device_software_version: str - :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long - :ivar time_zone: The Data Box Edge/Gateway device timezone. - :vartype time_zone: str - :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). - :vartype device_hcs_version: str - :ivar configured_role_types: Type of compute roles configured. - :vartype configured_role_types: list[str or - ~azure.mgmt.databoxedge.v2019_03_01.models.RoleTypes] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'serial_number': {'readonly': True}, - 'device_type': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - self.etag = kwargs.get('etag', None) - self.data_box_edge_device_status = kwargs.get('data_box_edge_device_status', None) - self.serial_number = None - self.description = kwargs.get('description', None) - self.model_description = kwargs.get('model_description', None) - self.device_type = None - self.friendly_name = kwargs.get('friendly_name', None) - self.culture = None - self.device_model = None - self.device_software_version = None - self.device_local_capacity = None - self.time_zone = None - self.device_hcs_version = None - self.configured_role_types = None - - -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): - """The extended Info of the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to - encrypt any secret. - :type encryption_key: str - :ivar resource_key: The Resource ID of the Resource. - :vartype resource_key: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) - self.encryption_key_thumbprint = kwargs.get('encryption_key_thumbprint', None) - self.encryption_key = kwargs.get('encryption_key', None) - self.resource_key = None - - -class DataBoxEdgeDeviceList(msrest.serialization.Model): - """The collection of Data Box Edge/Gateway devices. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Data Box Edge/Gateway devices. - :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevicePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device patch. - - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class Trigger(ARMBaseModel): - """Trigger details. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.TriggerEventType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } - - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.kind = 'Trigger' # type: str - - -class FileEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2019_03_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2019_03_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class FileSourceInfo(msrest.serialization.Model): - """File source details. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. File share ID. - :type share_id: str - """ - - _validation = { - 'share_id': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - - -class IoTDeviceInfo(msrest.serialization.Model): - """Metadata of IoT device/IoT Edge device to be configured. - - All required parameters must be populated in order to send to Azure. - - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param authentication: IoT device authentication info. - :type authentication: ~azure.mgmt.databoxedge.v2019_03_01.models.Authentication - """ - - _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) - self.device_id = kwargs['device_id'] - self.io_t_host_hub = kwargs['io_t_host_hub'] - self.authentication = kwargs.get('authentication', None) - - -class Role(ARMBaseModel): - """Compute role. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: IoTRole. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleTypes - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'IOT': 'IoTRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str - - -class IoTRole(Role): - """Compute role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleTypes - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", - "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2019_03_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2019_03_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_03_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2019_03_01.models.MountPointMap] - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.io_t_device_details = kwargs.get('io_t_device_details', None) - self.io_t_edge_device_details = kwargs.get('io_t_edge_device_details', None) - self.share_mappings = kwargs.get('share_mappings', None) - self.role_status = kwargs.get('role_status', None) - - -class Ipv4Config(msrest.serialization.Model): - """Details related to the IPv4 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv4 address of the network adapter. - :vartype ip_address: str - :ivar subnet: The IPv4 subnet of the network adapter. - :vartype subnet: str - :ivar gateway: The IPv4 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) - self.ip_address = None - self.subnet = None - self.gateway = None - - -class Ipv6Config(msrest.serialization.Model): - """Details related to the IPv6 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv6 address of the network adapter. - :vartype ip_address: str - :ivar prefix_length: The IPv6 prefix of the network adapter. - :vartype prefix_length: int - :ivar gateway: The IPv6 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) - self.ip_address = None - self.prefix_length = None - self.gateway = None - - -class Job(msrest.serialization.Model): - """A device job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The name of the object. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.JobStatus - :ivar start_time: The UTC date and time at which the job started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The UTC date and time at which the job completed. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: The percentage of the job that is complete. - :vartype percent_complete: int - :ivar error: The error details. - :vartype error: ~azure.mgmt.databoxedge.v2019_03_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare". - :vartype job_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", - "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", - "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". - :vartype current_stage: str or ~azure.mgmt.databoxedge.v2019_03_01.models.UpdateOperationStage - :ivar download_progress: The download progress. - :vartype download_progress: ~azure.mgmt.databoxedge.v2019_03_01.models.UpdateDownloadProgress - :ivar install_progress: The install progress. - :vartype install_progress: ~azure.mgmt.databoxedge.v2019_03_01.models.UpdateInstallProgress - :ivar total_refresh_errors: Total number of errors encountered during the refresh process. - :vartype total_refresh_errors: int - :ivar error_manifest_file: Local share/remote container relative path to the error manifest - file of the refresh. - :vartype error_manifest_file: str - :ivar share_id: ARM ID of the share that was refreshed. - :vartype share_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'share_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'share_id': {'key': 'properties.shareId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_time = None - self.end_time = None - self.percent_complete = None - self.error = None - self.job_type = None - self.current_stage = None - self.download_progress = None - self.install_progress = None - self.total_refresh_errors = None - self.error_manifest_file = None - self.share_id = None - self.folder = kwargs.get('folder', None) - - -class JobErrorDetails(msrest.serialization.Model): - """The job error information containing the list of job errors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_details: The error details. - :vartype error_details: list[~azure.mgmt.databoxedge.v2019_03_01.models.JobErrorItem] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) - self.error_details = None - self.code = None - self.message = None - - -class JobErrorItem(msrest.serialization.Model): - """The job error items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendations: The recommended actions. - :vartype recommendations: list[str] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) - self.recommendations = None - self.code = None - self.message = None - - -class MetricDimensionV1(msrest.serialization.Model): - """Metric Dimension v1. - - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimensionV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecificationV1(msrest.serialization.Model): - """Metric specification version 1. - - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2019_03_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or - ~azure.mgmt.databoxedge.v2019_03_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or - ~azure.mgmt.databoxedge.v2019_03_01.models.MetricAggregationType] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.dimensions = kwargs.get('dimensions', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - - -class MountPointMap(msrest.serialization.Model): - """The share mount point. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str - :ivar role_id: ID of the role to which share is mounted. - :vartype role_id: str - :ivar mount_point: Mount point for the share. - :vartype mount_point: str - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive". - :vartype role_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleTypes - """ - - _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'role_type': {'readonly': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.role_id = None - self.mount_point = None - self.role_type = None - - -class NetworkAdapter(msrest.serialization.Model): - """Represents the networkAdapter on a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar adapter_id: Instance ID of network adapter. - :vartype adapter_id: str - :ivar adapter_position: Hardware position of network adapter. - :vartype adapter_position: ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterPosition - :ivar index: Logical index of the adapter. - :vartype index: int - :ivar node_id: Node ID of the network adapter. - :vartype node_id: str - :ivar network_adapter_name: Network adapter name. - :vartype network_adapter_name: str - :ivar label: Hardware label for the adapter. - :vartype label: str - :ivar mac_address: MAC address. - :vartype mac_address: str - :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". - :vartype status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterDHCPStatus - :ivar ipv4_configuration: The IPv4 configuration of the network adapter. - :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2019_03_01.models.Ipv4Config - :ivar ipv6_configuration: The IPv6 configuration of the network adapter. - :vartype ipv6_configuration: ~azure.mgmt.databoxedge.v2019_03_01.models.Ipv6Config - :ivar ipv6_link_local_address: The IPv6 local address. - :vartype ipv6_link_local_address: str - :ivar dns_servers: The list of DNS Servers of the device. - :vartype dns_servers: list[str] - """ - - _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) - self.adapter_id = None - self.adapter_position = None - self.index = None - self.node_id = None - self.network_adapter_name = None - self.label = None - self.mac_address = None - self.link_speed = None - self.status = None - self.rdma_status = kwargs.get('rdma_status', None) - self.dhcp_status = kwargs.get('dhcp_status', None) - self.ipv4_configuration = None - self.ipv6_configuration = None - self.ipv6_link_local_address = None - self.dns_servers = None - - -class NetworkAdapterPosition(msrest.serialization.Model): - """The network adapter position. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". - :vartype network_group: str or ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkGroup - :ivar port: The port. - :vartype port: int - """ - - _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, - } - - _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) - self.network_group = None - self.port = None - - -class NetworkSettings(ARMBaseModel): - """The network settings of a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar network_adapters: The network adapter list on the device. - :vartype network_adapters: list[~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapter] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) - self.network_adapters = None - - -class Operation(msrest.serialization.Model): - """Operations. - - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2019_03_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2019_03_01.models.ServiceSpecification - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationDisplay(msrest.serialization.Model): - """Operation display properties. - - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str - """ - - _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 = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """The list of operations used for the discovery of available provider operations. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2019_03_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class Order(ARMBaseModel): - """The order details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2019_03_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2019_03_01.models.Address - :param current_status: Current status of the order. - :type current_status: ~azure.mgmt.databoxedge.v2019_03_01.models.OrderStatus - :ivar order_history: List of status changes in the order. - :vartype order_history: list[~azure.mgmt.databoxedge.v2019_03_01.models.OrderStatus] - :ivar serial_number: Serial number of the device. - :vartype serial_number: str - :ivar delivery_tracking_info: Tracking information for the package delivered to the customer - whether it has an original or a replacement device. - :vartype delivery_tracking_info: list[~azure.mgmt.databoxedge.v2019_03_01.models.TrackingInfo] - :ivar return_tracking_info: Tracking information for the package returned from the customer - whether it has an original or a replacement device. - :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2019_03_01.models.TrackingInfo] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(Order, self).__init__(**kwargs) - self.contact_information = kwargs.get('contact_information', None) - self.shipping_address = kwargs.get('shipping_address', None) - self.current_status = kwargs.get('current_status', None) - self.order_history = None - self.serial_number = None - self.delivery_tracking_info = None - self.return_tracking_info = None - - -class OrderList(msrest.serialization.Model): - """List of order entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of orders. - :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.Order] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OrderStatus(msrest.serialization.Model): - """Represents a single status change. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft". - :type status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.OrderState - :ivar update_date_time: Time of status update. - :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str - """ - - _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) - self.status = kwargs['status'] - self.update_date_time = None - self.comments = kwargs.get('comments', None) - - -class PeriodicTimerEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2019_03_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2019_03_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class PeriodicTimerSourceInfo(msrest.serialization.Model): - """Periodic timer event source. - - All required parameters must be populated in order to send to Azure. - - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified up to seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str - """ - - _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) - self.start_time = kwargs['start_time'] - self.schedule = kwargs['schedule'] - self.topic = kwargs.get('topic', None) - - -class RefreshDetails(msrest.serialization.Model): - """Fields for tracking refresh job on the share. - - :param in_progress_refresh_job_id: If a refresh share job is currently in progress on this - share, this field indicates the ARM resource ID of that job. The field is empty if no job is in - progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share, if any.This could be a failed job or a successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh - job on this particular share, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share,if any. This - could be a failed job or a successful job. - :type last_job: str - """ - - _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RefreshDetails, self).__init__(**kwargs) - self.in_progress_refresh_job_id = kwargs.get('in_progress_refresh_job_id', None) - self.last_completed_refresh_job_time_in_utc = kwargs.get('last_completed_refresh_job_time_in_utc', None) - self.error_manifest_file = kwargs.get('error_manifest_file', None) - self.last_job = kwargs.get('last_job', None) - - -class RoleList(msrest.serialization.Model): - """Collection of all the roles on the Data Box Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.Role] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RoleSinkInfo(msrest.serialization.Model): - """Compute role against which events will be raised. - - All required parameters must be populated in order to send to Azure. - - :param role_id: Required. Compute role ID. - :type role_id: str - """ - - _validation = { - 'role_id': {'required': True}, - } - - _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) - self.role_id = kwargs['role_id'] - - -class SecuritySettings(ARMBaseModel): - """The security settings of a device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: - ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) - self.device_admin_password = kwargs['device_admin_password'] - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification. - - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: - list[~azure.mgmt.databoxedge.v2019_03_01.models.MetricSpecificationV1] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Share(ARMBaseModel): - """Represents a share on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Online", - "Offline". - :type share_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2019_03_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share - (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2019_03_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the - share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2019_03_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2019_03_01.models.RefreshDetails - :ivar share_mappings: Share mount point to the role. - :vartype share_mappings: list[~azure.mgmt.databoxedge.v2019_03_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2019_03_01.models.DataPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Share, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.share_status = kwargs['share_status'] - self.monitoring_status = kwargs['monitoring_status'] - self.azure_container_info = kwargs.get('azure_container_info', None) - self.access_protocol = kwargs['access_protocol'] - self.user_access_rights = kwargs.get('user_access_rights', None) - self.client_access_rights = kwargs.get('client_access_rights', None) - self.refresh_details = kwargs.get('refresh_details', None) - self.share_mappings = None - self.data_policy = kwargs.get('data_policy', None) - - -class ShareAccessRight(msrest.serialization.Model): - """Specifies the mapping between this particular user and the type of access he has on shares on this device. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessType - """ - - _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.access_type = kwargs['access_type'] - - -class ShareList(msrest.serialization.Model): - """Collection of all the shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of shares. - :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.Share] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Sku(msrest.serialization.Model): - """The SKU type. - - :param name: SKU name. Possible values include: "Gateway", "Edge". - :type name: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SkuTier - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - - -class StorageAccountCredential(ARMBaseModel): - """The storage account credential. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AccountType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredential, self).__init__(**kwargs) - self.alias = kwargs['alias'] - self.user_name = kwargs.get('user_name', None) - self.account_key = kwargs.get('account_key', None) - self.connection_string = kwargs.get('connection_string', None) - self.ssl_status = kwargs['ssl_status'] - self.blob_domain_name = kwargs.get('blob_domain_name', None) - self.account_type = kwargs['account_type'] - - -class StorageAccountCredentialList(msrest.serialization.Model): - """The collection of storage account credentials. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SymmetricKey(msrest.serialization.Model): - """Symmetric key for authentication. - - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret - """ - - _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) - self.connection_string = kwargs.get('connection_string', None) - - -class TrackingInfo(msrest.serialization.Model): - """Tracking courier information. - - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str - """ - - _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackingInfo, self).__init__(**kwargs) - self.serial_number = kwargs.get('serial_number', None) - self.carrier_name = kwargs.get('carrier_name', None) - self.tracking_id = kwargs.get('tracking_id', None) - self.tracking_url = kwargs.get('tracking_url', None) - - -class TriggerList(msrest.serialization.Model): - """Collection of all trigger on the data box edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of triggers. - :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.Trigger] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UpdateDownloadProgress(msrest.serialization.Model): - """Details about the download progress of update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". - :vartype download_phase: str or ~azure.mgmt.databoxedge.v2019_03_01.models.DownloadPhase - :ivar percent_complete: Percentage of completion. - :vartype percent_complete: int - :ivar total_bytes_to_download: Total bytes to download. - :vartype total_bytes_to_download: float - :ivar total_bytes_downloaded: Total bytes downloaded. - :vartype total_bytes_downloaded: float - :ivar number_of_updates_to_download: Number of updates to download. - :vartype number_of_updates_to_download: int - :ivar number_of_updates_downloaded: Number of updates downloaded. - :vartype number_of_updates_downloaded: int - """ - - _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, - } - - _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) - self.download_phase = None - self.percent_complete = None - self.total_bytes_to_download = None - self.total_bytes_downloaded = None - self.number_of_updates_to_download = None - self.number_of_updates_downloaded = None - - -class UpdateInstallProgress(msrest.serialization.Model): - """Progress details during installation of updates. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar percent_complete: Percentage completed. - :vartype percent_complete: int - :ivar number_of_updates_to_install: Number of updates to install. - :vartype number_of_updates_to_install: int - :ivar number_of_updates_installed: Number of updates installed. - :vartype number_of_updates_installed: int - """ - - _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, - } - - _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) - self.percent_complete = None - self.number_of_updates_to_install = None - self.number_of_updates_installed = None - - -class UpdateSummary(ARMBaseModel): - """Details about ongoing updates and availability of updates on the device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed - (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime - :ivar last_completed_download_job_date_time: The time when the last Download job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_download_job_date_time: ~datetime.datetime - :ivar last_completed_install_job_date_time: The time when the last Install job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_install_job_date_time: ~datetime.datetime - :ivar total_number_of_updates_available: The number of updates available for the current device - version as per the last device scan. - :vartype total_number_of_updates_available: int - :ivar total_number_of_updates_pending_download: The total number of items pending download. - :vartype total_number_of_updates_pending_download: int - :ivar total_number_of_updates_pending_install: The total number of items pending install. - :vartype total_number_of_updates_pending_install: int - :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.databoxedge.v2019_03_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". - :vartype ongoing_update_operation: str or - ~azure.mgmt.databoxedge.v2019_03_01.models.UpdateOperation - :ivar in_progress_download_job_id: The job ID of the download job in progress. - :vartype in_progress_download_job_id: str - :ivar in_progress_install_job_id: The job ID of the install job in progress. - :vartype in_progress_install_job_id: str - :ivar in_progress_download_job_started_date_time: The time when the currently running download - (if any) started. - :vartype in_progress_download_job_started_date_time: ~datetime.datetime - :ivar in_progress_install_job_started_date_time: The time when the currently running install - (if any) started. - :vartype in_progress_install_job_started_date_time: ~datetime.datetime - :ivar update_titles: The list of updates available for install. - :vartype update_titles: list[str] - :ivar total_update_size_in_bytes: The total size of updates available for download in bytes. - :vartype total_update_size_in_bytes: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateSummary, self).__init__(**kwargs) - self.device_version_number = kwargs.get('device_version_number', None) - self.friendly_device_version_name = kwargs.get('friendly_device_version_name', None) - self.device_last_scanned_date_time = kwargs.get('device_last_scanned_date_time', None) - self.last_completed_scan_job_date_time = kwargs.get('last_completed_scan_job_date_time', None) - self.last_completed_download_job_date_time = None - self.last_completed_install_job_date_time = None - self.total_number_of_updates_available = None - self.total_number_of_updates_pending_download = None - self.total_number_of_updates_pending_install = None - self.reboot_behavior = None - self.ongoing_update_operation = None - self.in_progress_download_job_id = None - self.in_progress_install_job_id = None - self.in_progress_download_job_started_date_time = None - self.in_progress_install_job_started_date_time = None - self.update_titles = None - self.total_update_size_in_bytes = None - - -class UploadCertificateRequest(msrest.serialization.Model): - """The upload certificate request. - - All required parameters must be populated in order to send to Azure. - - :param authentication_type: The authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str - """ - - _validation = { - 'certificate': {'required': True}, - } - - _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) - self.authentication_type = kwargs.get('authentication_type', None) - self.certificate = kwargs['certificate'] - - -class UploadCertificateResponse(msrest.serialization.Model): - """The upload registration certificate response. - - All required parameters must be populated in order to send to Azure. - - :param auth_type: Specifies authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AuthenticationType - :param resource_id: Required. The resource ID of the Data Box Edge/Gateway device. - :type resource_id: str - :param aad_authority: Required. Azure Active Directory tenant authority. - :type aad_authority: str - :param aad_tenant_id: Required. Azure Active Directory tenant ID. - :type aad_tenant_id: str - :param service_principal_client_id: Required. Azure Active Directory service principal client - ID. - :type service_principal_client_id: str - :param service_principal_object_id: Required. Azure Active Directory service principal object - ID. - :type service_principal_object_id: str - :param azure_management_endpoint_audience: Required. The azure management endpoint audience. - :type azure_management_endpoint_audience: str - """ - - _validation = { - 'resource_id': {'required': True}, - 'aad_authority': {'required': True}, - 'aad_tenant_id': {'required': True}, - 'service_principal_client_id': {'required': True}, - 'service_principal_object_id': {'required': True}, - 'azure_management_endpoint_audience': {'required': True}, - } - - _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) - self.auth_type = kwargs.get('auth_type', None) - self.resource_id = kwargs['resource_id'] - self.aad_authority = kwargs['aad_authority'] - self.aad_tenant_id = kwargs['aad_tenant_id'] - self.service_principal_client_id = kwargs['service_principal_client_id'] - self.service_principal_object_id = kwargs['service_principal_object_id'] - self.azure_management_endpoint_audience = kwargs['azure_management_endpoint_audience'] - - -class User(ARMBaseModel): - """Represents a user who has access to one or more shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret - :param share_access_rights: List of shares that the user has rights on. This field should not - be specified during user creation. - :type share_access_rights: list[~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessRight] - """ - - _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'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.encrypted_password = kwargs.get('encrypted_password', None) - self.share_access_rights = kwargs.get('share_access_rights', None) - - -class UserAccessRight(msrest.serialization.Model): - """The mapping between a particular user and the access type on the SMB share. - - All required parameters must be populated in order to send to Azure. - - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessType - """ - - _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) - self.user_id = kwargs['user_id'] - self.access_type = kwargs['access_type'] - - -class UserList(msrest.serialization.Model): - """Collection of users. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of users. - :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.User] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) - self.value = None - self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_models_py3.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_models_py3.py index 14dd7a6c2d22..f0c475efb0e6 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_models_py3.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,50 +8,52 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._data_box_edge_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Address(msrest.serialization.Model): +class Address(_serialization.Model): """The shipping address of the customer. All required parameters must be populated in order to send to Azure. - :param address_line1: Required. The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: Required. The postal code. - :type postal_code: str - :param city: Required. The city name. - :type city: str - :param state: Required. The state name. - :type state: str - :param country: Required. The country name. - :type country: str + :ivar address_line1: The address line1. Required. + :vartype address_line1: str + :ivar address_line2: The address line2. + :vartype address_line2: str + :ivar address_line3: The address line3. + :vartype address_line3: str + :ivar postal_code: The postal code. Required. + :vartype postal_code: str + :ivar city: The city name. Required. + :vartype city: str + :ivar state: The state name. Required. + :vartype state: str + :ivar country: The country name. Required. + :vartype country: str """ _validation = { - 'address_line1': {'required': True}, - 'postal_code': {'required': True}, - 'city': {'required': True}, - 'state': {'required': True}, - 'country': {'required': True}, + "address_line1": {"required": True}, + "postal_code": {"required": True}, + "city": {"required": True}, + "state": {"required": True}, + "country": {"required": True}, } _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, + "address_line1": {"key": "addressLine1", "type": "str"}, + "address_line2": {"key": "addressLine2", "type": "str"}, + "address_line3": {"key": "addressLine3", "type": "str"}, + "postal_code": {"key": "postalCode", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "country": {"key": "country", "type": "str"}, } def __init__( @@ -65,7 +68,23 @@ def __init__( address_line3: Optional[str] = None, **kwargs ): - super(Address, self).__init__(**kwargs) + """ + :keyword address_line1: The address line1. Required. + :paramtype address_line1: str + :keyword address_line2: The address line2. + :paramtype address_line2: str + :keyword address_line3: The address line3. + :paramtype address_line3: str + :keyword postal_code: The postal code. Required. + :paramtype postal_code: str + :keyword city: The city name. Required. + :paramtype city: str + :keyword state: The state name. Required. + :paramtype state: str + :keyword country: The country name. Required. + :paramtype country: str + """ + super().__init__(**kwargs) self.address_line1 = address_line1 self.address_line2 = address_line2 self.address_line3 = address_line3 @@ -75,7 +94,7 @@ def __init__( self.country = country -class ARMBaseModel(msrest.serialization.Model): +class ARMBaseModel(_serialization.Model): """Represents the base class for all object models. Variables are only populated by the server, and will be ignored when sending a request. @@ -89,22 +108,20 @@ class ARMBaseModel(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -129,7 +146,7 @@ class Alert(ARMBaseModel): :vartype appeared_at_date_time: ~datetime.datetime :ivar recommendation: Alert recommendation. :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", + :ivar severity: Severity of the alert. Known values are: "Informational", "Warning", and "Critical". :vartype severity: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AlertSeverity :ivar error_details: Error details of the alert. @@ -139,36 +156,34 @@ class Alert(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "title": {"readonly": True}, + "alert_type": {"readonly": True}, + "appeared_at_date_time": {"readonly": True}, + "recommendation": {"readonly": True}, + "severity": {"readonly": True}, + "error_details": {"readonly": True}, + "detailed_information": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "title": {"key": "properties.title", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "appeared_at_date_time": {"key": "properties.appearedAtDateTime", "type": "iso-8601"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "error_details": {"key": "properties.errorDetails", "type": "AlertErrorDetails"}, + "detailed_information": {"key": "properties.detailedInformation", "type": "{str}"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.title = None self.alert_type = None self.appeared_at_date_time = None @@ -178,7 +193,7 @@ def __init__( self.detailed_information = None -class AlertErrorDetails(msrest.serialization.Model): +class AlertErrorDetails(_serialization.Model): """Error details for the alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -192,28 +207,26 @@ class AlertErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, + "error_code": {"readonly": True}, + "error_message": {"readonly": True}, + "occurrences": {"readonly": True}, } _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "occurrences": {"key": "occurrences", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_code = None self.error_message = None self.occurrences = None -class AlertList(msrest.serialization.Model): +class AlertList(_serialization.Model): """Collection of alerts. Variables are only populated by the server, and will be ignored when sending a request. @@ -225,112 +238,121 @@ class AlertList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class AsymmetricEncryptedSecret(msrest.serialization.Model): +class AsymmetricEncryptedSecret(_serialization.Model): """Represent the secrets intended for encryption with asymmetric key pair. All required parameters must be populated in order to send to Azure. - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + :ivar value: The value of the secret. Required. + :vartype value: str + :ivar encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or + :vartype encryption_cert_thumbprint: str + :ivar encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values are: + "None", "AES256", and "RSAES_PKCS1_v_1_5". + :vartype encryption_algorithm: str or ~azure.mgmt.databoxedge.v2019_03_01.models.EncryptionAlgorithm """ _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, + "value": {"required": True}, + "encryption_algorithm": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "encryption_cert_thumbprint": {"key": "encryptionCertThumbprint", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, } def __init__( self, *, value: str, - encryption_algorithm: Union[str, "EncryptionAlgorithm"], + encryption_algorithm: Union[str, "_models.EncryptionAlgorithm"], encryption_cert_thumbprint: Optional[str] = None, **kwargs ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) + """ + :keyword value: The value of the secret. Required. + :paramtype value: str + :keyword encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :paramtype encryption_cert_thumbprint: str + :keyword encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values + are: "None", "AES256", and "RSAES_PKCS1_v_1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.EncryptionAlgorithm + """ + super().__init__(**kwargs) self.value = value self.encryption_cert_thumbprint = encryption_cert_thumbprint self.encryption_algorithm = encryption_algorithm -class Authentication(msrest.serialization.Model): +class Authentication(_serialization.Model): """Authentication mechanism for IoT devices. - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2019_03_01.models.SymmetricKey + :ivar symmetric_key: Symmetric key for authentication. + :vartype symmetric_key: ~azure.mgmt.databoxedge.v2019_03_01.models.SymmetricKey """ _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, + "symmetric_key": {"key": "symmetricKey", "type": "SymmetricKey"}, } - def __init__( - self, - *, - symmetric_key: Optional["SymmetricKey"] = None, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) + def __init__(self, *, symmetric_key: Optional["_models.SymmetricKey"] = None, **kwargs): + """ + :keyword symmetric_key: Symmetric key for authentication. + :paramtype symmetric_key: ~azure.mgmt.databoxedge.v2019_03_01.models.SymmetricKey + """ + super().__init__(**kwargs) self.symmetric_key = symmetric_key -class AzureContainerInfo(msrest.serialization.Model): +class AzureContainerInfo(_serialization.Model): """Azure container mapping of the endpoint. All required parameters must be populated in order to send to Azure. - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AzureContainerDataFormat + :ivar storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :vartype storage_account_credential_id: str + :ivar container_name: Container name (Based on the data format specified, this represents the + name of Azure Files/Page blob/Block blob). Required. + :vartype container_name: str + :ivar data_format: Storage format used for the file represented by the share. Required. Known + values are: "BlockBlob", "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.AzureContainerDataFormat """ _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, + "storage_account_credential_id": {"required": True}, + "container_name": {"required": True}, + "data_format": {"required": True}, } _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, + "storage_account_credential_id": {"key": "storageAccountCredentialId", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "data_format": {"key": "dataFormat", "type": "str"}, } def __init__( @@ -338,10 +360,22 @@ def __init__( *, storage_account_credential_id: str, container_name: str, - data_format: Union[str, "AzureContainerDataFormat"], - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) + data_format: Union[str, "_models.AzureContainerDataFormat"], + **kwargs + ): + """ + :keyword storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :paramtype storage_account_credential_id: str + :keyword container_name: Container name (Based on the data format specified, this represents + the name of Azure Files/Page blob/Block blob). Required. + :paramtype container_name: str + :keyword data_format: Storage format used for the file represented by the share. Required. + Known values are: "BlockBlob", "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.storage_account_credential_id = storage_account_credential_id self.container_name = container_name self.data_format = data_format @@ -360,53 +394,57 @@ class BandwidthSchedule(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2019_03_01.models.DayOfWeek] + :ivar start: The start time of the schedule in UTC. Required. + :vartype start: str + :ivar stop: The stop time of the schedule in UTC. Required. + :vartype stop: str + :ivar rate_in_mbps: The bandwidth rate in Mbps. Required. + :vartype rate_in_mbps: int + :ivar days: The days of the week when this schedule is applicable. Required. + :vartype days: list[str or ~azure.mgmt.databoxedge.v2019_03_01.models.DayOfWeek] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - *, - start: str, - stop: str, - rate_in_mbps: int, - days: List[Union[str, "DayOfWeek"]], - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "start": {"required": True}, + "stop": {"required": True}, + "rate_in_mbps": {"required": True}, + "days": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "start": {"key": "properties.start", "type": "str"}, + "stop": {"key": "properties.stop", "type": "str"}, + "rate_in_mbps": {"key": "properties.rateInMbps", "type": "int"}, + "days": {"key": "properties.days", "type": "[str]"}, + } + + def __init__( + self, *, start: str, stop: str, rate_in_mbps: int, days: List[Union[str, "_models.DayOfWeek"]], **kwargs + ): + """ + :keyword start: The start time of the schedule in UTC. Required. + :paramtype start: str + :keyword stop: The stop time of the schedule in UTC. Required. + :paramtype stop: str + :keyword rate_in_mbps: The bandwidth rate in Mbps. Required. + :paramtype rate_in_mbps: int + :keyword days: The days of the week when this schedule is applicable. Required. + :paramtype days: list[str or ~azure.mgmt.databoxedge.v2019_03_01.models.DayOfWeek] + """ + super().__init__(**kwargs) self.start = start self.stop = stop self.rate_in_mbps = rate_in_mbps self.days = days -class BandwidthSchedulesList(msrest.serialization.Model): +class BandwidthSchedulesList(_serialization.Model): """The collection of bandwidth schedules. Variables are only populated by the server, and will be ignored when sending a request. @@ -418,75 +456,76 @@ class BandwidthSchedulesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BandwidthSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ClientAccessRight(msrest.serialization.Model): +class ClientAccessRight(_serialization.Model): """The mapping between a particular client IP and the type of access client has on the NFS share. All required parameters must be populated in order to send to Azure. - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ClientPermissionType + :ivar client: IP of the client. Required. + :vartype client: str + :ivar access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :vartype access_permission: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.ClientPermissionType """ _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, + "client": {"required": True}, + "access_permission": {"required": True}, } _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, + "client": {"key": "client", "type": "str"}, + "access_permission": {"key": "accessPermission", "type": "str"}, } - def __init__( - self, - *, - client: str, - access_permission: Union[str, "ClientPermissionType"], - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) + def __init__(self, *, client: str, access_permission: Union[str, "_models.ClientPermissionType"], **kwargs): + """ + :keyword client: IP of the client. Required. + :paramtype client: str + :keyword access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :paramtype access_permission: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.ClientPermissionType + """ + super().__init__(**kwargs) self.client = client self.access_permission = access_permission -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2019_03_01.models.CloudErrorBody] + :vartype message: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.databoxedge.v2019_03_01.models.CloudErrorBody] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -494,61 +533,73 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.databoxedge.v2019_03_01.models.CloudErrorBody] + """ + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class ContactDetails(msrest.serialization.Model): +class ContactDetails(_serialization.Model): """Contains all the contact details of the customer. All required parameters must be populated in order to send to Azure. - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] + :ivar contact_person: The contact person name. Required. + :vartype contact_person: str + :ivar company_name: The name of the company. Required. + :vartype company_name: str + :ivar phone: The phone number. Required. + :vartype phone: str + :ivar email_list: The email list. Required. + :vartype email_list: list[str] """ _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - *, - contact_person: str, - company_name: str, - phone: str, - email_list: List[str], - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) + "contact_person": {"required": True}, + "company_name": {"required": True}, + "phone": {"required": True}, + "email_list": {"required": True}, + } + + _attribute_map = { + "contact_person": {"key": "contactPerson", "type": "str"}, + "company_name": {"key": "companyName", "type": "str"}, + "phone": {"key": "phone", "type": "str"}, + "email_list": {"key": "emailList", "type": "[str]"}, + } + + def __init__(self, *, contact_person: str, company_name: str, phone: str, email_list: List[str], **kwargs): + """ + :keyword contact_person: The contact person name. Required. + :paramtype contact_person: str + :keyword company_name: The name of the company. Required. + :paramtype company_name: str + :keyword phone: The phone number. Required. + :paramtype phone: str + :keyword email_list: The email list. Required. + :paramtype email_list: list[str] + """ + super().__init__(**kwargs) self.contact_person = contact_person self.company_name = company_name self.phone = phone self.email_list = email_list -class DataBoxEdgeDevice(ARMBaseModel): +class DataBoxEdgeDevice(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -561,34 +612,33 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure + :ivar location: The location of the device. This is a supported and registered Azure geographical region (for example, West US, East US, or Southeast Asia). The geographical region of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2019_03_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + specified on update, the request will succeed. Required. + :vartype location: str + :ivar tags: The list of tags that describe the device. These tags can be used to view and group + this device (across resource groups). + :vartype tags: dict[str, str] + :ivar sku: The SKU type. + :vartype sku: ~azure.mgmt.databoxedge.v2019_03_01.models.Sku + :ivar etag: The etag for the devices. + :vartype etag: str + :ivar data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known values + are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", and "PartiallyDisconnected". - :type data_box_edge_device_status: str or + :vartype data_box_edge_device_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDeviceStatus :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. :vartype serial_number: str - :param description: The Description of the Data Box Edge/Gateway device. - :type description: str - :param model_description: The description of the Data Box Edge/Gateway device model. - :type model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". + :ivar description: The Description of the Data Box Edge/Gateway device. + :vartype description: str + :ivar model_description: The description of the Data Box Edge/Gateway device model. + :vartype model_description: str + :ivar device_type: The type of the Data Box Edge/Gateway device. "DataBoxEdgeDevice" :vartype device_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.DeviceType - :param friendly_name: The Data Box Edge/Gateway device name. - :type friendly_name: str + :ivar friendly_name: The Data Box Edge/Gateway device name. + :vartype friendly_name: str :ivar culture: The Data Box Edge/Gateway device culture. :vartype culture: str :ivar device_model: The Data Box Edge/Gateway device model. @@ -596,7 +646,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :ivar device_software_version: The Data Box Edge/Gateway device software version. :vartype device_software_version: str :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long + :vartype device_local_capacity: int :ivar time_zone: The Data Box Edge/Gateway device timezone. :vartype time_zone: str :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). @@ -607,42 +657,42 @@ class DataBoxEdgeDevice(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'serial_number': {'readonly': True}, - 'device_type': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "serial_number": {"readonly": True}, + "device_type": {"readonly": True}, + "culture": {"readonly": True}, + "device_model": {"readonly": True}, + "device_software_version": {"readonly": True}, + "device_local_capacity": {"readonly": True}, + "time_zone": {"readonly": True}, + "device_hcs_version": {"readonly": True}, + "configured_role_types": {"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}"}, + "sku": {"key": "sku", "type": "Sku"}, + "etag": {"key": "etag", "type": "str"}, + "data_box_edge_device_status": {"key": "properties.dataBoxEdgeDeviceStatus", "type": "str"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "model_description": {"key": "properties.modelDescription", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "culture": {"key": "properties.culture", "type": "str"}, + "device_model": {"key": "properties.deviceModel", "type": "str"}, + "device_software_version": {"key": "properties.deviceSoftwareVersion", "type": "str"}, + "device_local_capacity": {"key": "properties.deviceLocalCapacity", "type": "int"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "device_hcs_version": {"key": "properties.deviceHcsVersion", "type": "str"}, + "configured_role_types": {"key": "properties.configuredRoleTypes", "type": "[str]"}, } def __init__( @@ -650,15 +700,40 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, etag: Optional[str] = None, - data_box_edge_device_status: Optional[Union[str, "DataBoxEdgeDeviceStatus"]] = None, + data_box_edge_device_status: Optional[Union[str, "_models.DataBoxEdgeDeviceStatus"]] = None, description: Optional[str] = None, model_description: Optional[str] = None, friendly_name: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) + """ + :keyword location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :paramtype location: str + :keyword tags: The list of tags that describe the device. These tags can be used to view and + group this device (across resource groups). + :paramtype tags: dict[str, str] + :keyword sku: The SKU type. + :paramtype sku: ~azure.mgmt.databoxedge.v2019_03_01.models.Sku + :keyword etag: The etag for the devices. + :paramtype etag: str + :keyword data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known + values are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", and + "PartiallyDisconnected". + :paramtype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDeviceStatus + :keyword description: The Description of the Data Box Edge/Gateway device. + :paramtype description: str + :keyword model_description: The description of the Data Box Edge/Gateway device model. + :paramtype model_description: str + :keyword friendly_name: The Data Box Edge/Gateway device name. + :paramtype friendly_name: str + """ + super().__init__(**kwargs) self.location = location self.tags = tags self.sku = sku @@ -689,45 +764,48 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to + :ivar encryption_key_thumbprint: The digital signature of encrypted certificate. + :vartype encryption_key_thumbprint: str + :ivar encryption_key: The public part of the encryption certificate. Client uses this to encrypt any secret. - :type encryption_key: str + :vartype encryption_key: str :ivar resource_key: The Resource ID of the Resource. :vartype resource_key: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_key": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encryption_key_thumbprint": {"key": "properties.encryptionKeyThumbprint", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "str"}, + "resource_key": {"key": "properties.resourceKey", "type": "str"}, } def __init__( - self, - *, - encryption_key_thumbprint: Optional[str] = None, - encryption_key: Optional[str] = None, - **kwargs + self, *, encryption_key_thumbprint: Optional[str] = None, encryption_key: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) + """ + :keyword encryption_key_thumbprint: The digital signature of encrypted certificate. + :paramtype encryption_key_thumbprint: str + :keyword encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :paramtype encryption_key: str + """ + super().__init__(**kwargs) self.encryption_key_thumbprint = encryption_key_thumbprint self.encryption_key = encryption_key self.resource_key = None -class DataBoxEdgeDeviceList(msrest.serialization.Model): +class DataBoxEdgeDeviceList(_serialization.Model): """The collection of Data Box Edge/Gateway devices. Variables are only populated by the server, and will be ignored when sending a request. @@ -739,50 +817,47 @@ class DataBoxEdgeDeviceList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevicePatch(msrest.serialization.Model): +class DataBoxEdgeDevicePatch(_serialization.Model): """The Data Box Edge/Gateway device patch. - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] + :ivar tags: The tags attached to the Data Box Edge/Gateway resource. + :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: The tags attached to the Data Box Edge/Gateway resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) self.tags = tags class Trigger(ARMBaseModel): """Trigger details. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FileEventTrigger, PeriodicTimerEventTrigger Variables are only populated by the server, and will be ignored when sending a request. @@ -794,35 +869,30 @@ class Trigger(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.TriggerEventType + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.TriggerEventType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } + _subtype_map = {"kind": {"FileEvent": "FileEventTrigger", "PeriodicTimerEvent": "PeriodicTimerEventTrigger"}} - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.kind = 'Trigger' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None class FileEventTrigger(Trigger): @@ -838,113 +908,124 @@ class FileEventTrigger(Trigger): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2019_03_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2019_03_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.TriggerEventType + :ivar source_info: File event source details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2019_03_01.models.FileSourceInfo + :ivar sink_info: Role sink info. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2019_03_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "FileSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "FileSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.FileSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str + """ + :keyword source_info: File event source details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2019_03_01.models.FileSourceInfo + :keyword sink_info: Role sink info. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2019_03_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "FileEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class FileSourceInfo(msrest.serialization.Model): +class FileSourceInfo(_serialization.Model): """File source details. All required parameters must be populated in order to send to Azure. - :param share_id: Required. File share ID. - :type share_id: str + :ivar share_id: File share ID. Required. + :vartype share_id: str """ _validation = { - 'share_id': {'required': True}, + "share_id": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: File share ID. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id -class IoTDeviceInfo(msrest.serialization.Model): +class IoTDeviceInfo(_serialization.Model): """Metadata of IoT device/IoT Edge device to be configured. All required parameters must be populated in order to send to Azure. - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param authentication: IoT device authentication info. - :type authentication: ~azure.mgmt.databoxedge.v2019_03_01.models.Authentication + :ivar device_id: ID of the IoT device/edge device. Required. + :vartype device_id: str + :ivar io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :vartype io_t_host_hub: str + :ivar authentication: IoT device authentication info. + :vartype authentication: ~azure.mgmt.databoxedge.v2019_03_01.models.Authentication """ _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, + "device_id": {"required": True}, + "io_t_host_hub": {"required": True}, } _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, + "device_id": {"key": "deviceId", "type": "str"}, + "io_t_host_hub": {"key": "ioTHostHub", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, } def __init__( - self, - *, - device_id: str, - io_t_host_hub: str, - authentication: Optional["Authentication"] = None, - **kwargs + self, *, device_id: str, io_t_host_hub: str, authentication: Optional["_models.Authentication"] = None, **kwargs ): - super(IoTDeviceInfo, self).__init__(**kwargs) + """ + :keyword device_id: ID of the IoT device/edge device. Required. + :paramtype device_id: str + :keyword io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :paramtype io_t_host_hub: str + :keyword authentication: IoT device authentication info. + :paramtype authentication: ~azure.mgmt.databoxedge.v2019_03_01.models.Authentication + """ + super().__init__(**kwargs) self.device_id = device_id self.io_t_host_hub = io_t_host_hub self.authentication = authentication @@ -953,8 +1034,8 @@ def __init__( class Role(ARMBaseModel): """Compute role. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: IoTRole. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + IoTRole Variables are only populated by the server, and will be ignored when sending a request. @@ -966,35 +1047,30 @@ class Role(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", and "Cognitive". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleTypes """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'IOT': 'IoTRole'} - } + _subtype_map = {"kind": {"IOT": "IoTRole"}} - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None class IoTRole(Role): @@ -1010,54 +1086,68 @@ class IoTRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleTypes - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", and "Cognitive". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleTypes + :ivar host_platform: Host OS supported by the IoT role. Known values are: "Windows" and "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2019_03_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2019_03_01.models.PlatformType + :ivar io_t_device_details: IoT device metadata to which data box edge device needs to be connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2019_03_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_03_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2019_03_01.models.MountPointMap] - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleStatus + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2019_03_01.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_03_01.models.IoTDeviceInfo + :ivar share_mappings: Mount points of shares in role(s). + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2019_03_01.models.MountPointMap] + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - io_t_device_details: Optional["IoTDeviceInfo"] = None, - io_t_edge_device_details: Optional["IoTDeviceInfo"] = None, - share_mappings: Optional[List["MountPointMap"]] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + io_t_device_details: Optional["_models.IoTDeviceInfo"] = None, + io_t_edge_device_details: Optional["_models.IoTDeviceInfo"] = None, + share_mappings: Optional[List["_models.MountPointMap"]] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, + **kwargs + ): + """ + :keyword host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :paramtype host_platform: str or ~azure.mgmt.databoxedge.v2019_03_01.models.PlatformType + :keyword io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :paramtype io_t_device_details: ~azure.mgmt.databoxedge.v2019_03_01.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT role needs to be + configured. + :paramtype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_03_01.models.IoTDeviceInfo + :keyword share_mappings: Mount points of shares in role(s). + :paramtype share_mappings: list[~azure.mgmt.databoxedge.v2019_03_01.models.MountPointMap] + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "IOT" self.host_platform = host_platform self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details @@ -1065,7 +1155,7 @@ def __init__( self.role_status = role_status -class Ipv4Config(msrest.serialization.Model): +class Ipv4Config(_serialization.Model): """Details related to the IPv4 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1079,28 +1169,26 @@ class Ipv4Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "subnet": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.subnet = None self.gateway = None -class Ipv6Config(msrest.serialization.Model): +class Ipv6Config(_serialization.Model): """Details related to the IPv6 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1114,28 +1202,26 @@ class Ipv6Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "prefix_length": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "int"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.prefix_length = None self.gateway = None -class Job(msrest.serialization.Model): +class Job(_serialization.Model): # pylint: disable=too-many-instance-attributes """A device job. Variables are only populated by the server, and will be ignored when sending a request. @@ -1146,8 +1232,8 @@ class Job(msrest.serialization.Model): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar status: The current status of the job. Known values are: "Invalid", "Running", + "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.JobStatus :ivar start_time: The UTC date and time at which the job started. :vartype start_time: ~datetime.datetime @@ -1157,13 +1243,13 @@ class Job(msrest.serialization.Model): :vartype percent_complete: int :ivar error: The error details. :vartype error: ~azure.mgmt.databoxedge.v2019_03_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare". + :ivar job_type: The type of the job. Known values are: "Invalid", "ScanForUpdates", + "DownloadUpdates", "InstallUpdates", and "RefreshShare". :vartype job_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", + :ivar current_stage: Current stage of the update operation. Known values are: "Unknown", "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". + "Success", "Failure", "RescanStarted", "RescanComplete", and "RescanFailed". :vartype current_stage: str or ~azure.mgmt.databoxedge.v2019_03_01.models.UpdateOperationStage :ivar download_progress: The download progress. :vartype download_progress: ~azure.mgmt.databoxedge.v2019_03_01.models.UpdateDownloadProgress @@ -1176,55 +1262,55 @@ class Job(msrest.serialization.Model): :vartype error_manifest_file: str :ivar share_id: ARM ID of the share that was refreshed. :vartype share_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the + :ivar folder: If only subfolders need to be refreshed, then the subfolder path inside the share. (The path is empty if there are no subfolders.). - :type folder: str + :vartype folder: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'share_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'share_id': {'key': 'properties.shareId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - *, - folder: Optional[str] = None, - **kwargs - ): - super(Job, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "error": {"readonly": True}, + "job_type": {"readonly": True}, + "current_stage": {"readonly": True}, + "download_progress": {"readonly": True}, + "install_progress": {"readonly": True}, + "total_refresh_errors": {"readonly": True}, + "error_manifest_file": {"readonly": True}, + "share_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "error": {"key": "error", "type": "JobErrorDetails"}, + "job_type": {"key": "properties.jobType", "type": "str"}, + "current_stage": {"key": "properties.currentStage", "type": "str"}, + "download_progress": {"key": "properties.downloadProgress", "type": "UpdateDownloadProgress"}, + "install_progress": {"key": "properties.installProgress", "type": "UpdateInstallProgress"}, + "total_refresh_errors": {"key": "properties.totalRefreshErrors", "type": "int"}, + "error_manifest_file": {"key": "properties.errorManifestFile", "type": "str"}, + "share_id": {"key": "properties.shareId", "type": "str"}, + "folder": {"key": "properties.folder", "type": "str"}, + } + + def __init__(self, *, folder: Optional[str] = None, **kwargs): + """ + :keyword folder: If only subfolders need to be refreshed, then the subfolder path inside the + share. (The path is empty if there are no subfolders.). + :paramtype folder: str + """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1243,7 +1329,7 @@ def __init__( self.folder = folder -class JobErrorDetails(msrest.serialization.Model): +class JobErrorDetails(_serialization.Model): """The job error information containing the list of job errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -1257,28 +1343,26 @@ class JobErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "error_details": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "error_details": {"key": "errorDetails", "type": "[JobErrorItem]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_details = None self.code = None self.message = None -class JobErrorItem(msrest.serialization.Model): +class JobErrorItem(_serialization.Model): """The job error items. Variables are only populated by the server, and will be ignored when sending a request. @@ -1292,42 +1376,40 @@ class JobErrorItem(msrest.serialization.Model): """ _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "recommendations": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "recommendations": {"key": "recommendations", "type": "[str]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.recommendations = None self.code = None self.message = None -class MetricDimensionV1(msrest.serialization.Model): +class MetricDimensionV1(_serialization.Model): """Metric Dimension v1. - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the metrics dimension. + :vartype name: str + :ivar display_name: Display name of the metrics dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -1338,55 +1420,64 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(MetricDimensionV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metrics dimension. + :paramtype name: str + :keyword display_name: Display name of the metrics dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecificationV1(msrest.serialization.Model): +class MetricSpecificationV1(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric specification version 1. - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2019_03_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Description of the metric to be displayed. + :vartype display_description: str + :ivar unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :vartype unit: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricUnit + :ivar aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :vartype aggregation_type: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.MetricAggregationType + :ivar dimensions: Metric dimensions, other than default dimension which is resource. + :vartype dimensions: list[~azure.mgmt.databoxedge.v2019_03_01.models.MetricDimensionV1] + :ivar fill_gap_with_zero: Set true to fill the gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar category: Metric category. Known values are: "Capacity" and "Transaction". + :vartype category: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricCategory + :ivar resource_id_dimension_name_override: Resource name override. + :vartype resource_id_dimension_name_override: str + :ivar supported_time_grain_types: Support granularity of metrics. + :vartype supported_time_grain_types: list[str or ~azure.mgmt.databoxedge.v2019_03_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricAggregationType] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimensionV1]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, } def __init__( @@ -1395,17 +1486,46 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, display_description: Optional[str] = None, - unit: Optional[Union[str, "MetricUnit"]] = None, - aggregation_type: Optional[Union[str, "MetricAggregationType"]] = None, - dimensions: Optional[List["MetricDimensionV1"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, + dimensions: Optional[List["_models.MetricDimensionV1"]] = None, fill_gap_with_zero: Optional[bool] = None, - category: Optional[Union[str, "MetricCategory"]] = None, + category: Optional[Union[str, "_models.MetricCategory"]] = None, resource_id_dimension_name_override: Optional[str] = None, - supported_time_grain_types: Optional[List[Union[str, "TimeGrain"]]] = None, - supported_aggregation_types: Optional[List[Union[str, "MetricAggregationType"]]] = None, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) + supported_time_grain_types: Optional[List[Union[str, "_models.TimeGrain"]]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, + **kwargs + ): + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Description of the metric to be displayed. + :paramtype display_description: str + :keyword unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :paramtype unit: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricUnit + :keyword aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :paramtype aggregation_type: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.MetricAggregationType + :keyword dimensions: Metric dimensions, other than default dimension which is resource. + :paramtype dimensions: list[~azure.mgmt.databoxedge.v2019_03_01.models.MetricDimensionV1] + :keyword fill_gap_with_zero: Set true to fill the gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: Metric category. Known values are: "Capacity" and "Transaction". + :paramtype category: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MetricCategory + :keyword resource_id_dimension_name_override: Resource name override. + :paramtype resource_id_dimension_name_override: str + :keyword supported_time_grain_types: Support granularity of metrics. + :paramtype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2019_03_01.models.TimeGrain] + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2019_03_01.models.MetricAggregationType] + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1419,51 +1539,50 @@ def __init__( self.supported_aggregation_types = supported_aggregation_types -class MountPointMap(msrest.serialization.Model): +class MountPointMap(_serialization.Model): """The share mount point. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str + :ivar share_id: ID of the share mounted to the role VM. Required. + :vartype share_id: str :ivar role_id: ID of the role to which share is mounted. :vartype role_id: str :ivar mount_point: Mount point for the share. :vartype mount_point: str - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive". + :ivar role_type: Role type. Known values are: "IOT", "ASA", "Functions", and "Cognitive". :vartype role_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.RoleTypes """ _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'role_type': {'readonly': True}, + "share_id": {"required": True}, + "role_id": {"readonly": True}, + "mount_point": {"readonly": True}, + "role_type": {"readonly": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "mount_point": {"key": "mountPoint", "type": "str"}, + "role_type": {"key": "roleType", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: ID of the share mounted to the role VM. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id self.role_id = None self.mount_point = None self.role_type = None -class NetworkAdapter(msrest.serialization.Model): +class NetworkAdapter(_serialization.Model): # pylint: disable=too-many-instance-attributes """Represents the networkAdapter on a device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1483,16 +1602,18 @@ class NetworkAdapter(msrest.serialization.Model): :ivar mac_address: MAC address. :vartype mac_address: str :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". + :vartype link_speed: int + :ivar status: Value indicating whether this adapter is valid. Known values are: "Inactive" and + "Active". :vartype status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterDHCPStatus + :ivar rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :vartype rdma_status: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterRDMAStatus + :ivar dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :vartype dhcp_status: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterDHCPStatus :ivar ipv4_configuration: The IPv4 configuration of the network adapter. :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2019_03_01.models.Ipv4Config :ivar ipv6_configuration: The IPv6 configuration of the network adapter. @@ -1504,47 +1625,57 @@ class NetworkAdapter(msrest.serialization.Model): """ _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, + "adapter_id": {"readonly": True}, + "adapter_position": {"readonly": True}, + "index": {"readonly": True}, + "node_id": {"readonly": True}, + "network_adapter_name": {"readonly": True}, + "label": {"readonly": True}, + "mac_address": {"readonly": True}, + "link_speed": {"readonly": True}, + "status": {"readonly": True}, + "ipv4_configuration": {"readonly": True}, + "ipv6_configuration": {"readonly": True}, + "ipv6_link_local_address": {"readonly": True}, + "dns_servers": {"readonly": True}, + } + + _attribute_map = { + "adapter_id": {"key": "adapterId", "type": "str"}, + "adapter_position": {"key": "adapterPosition", "type": "NetworkAdapterPosition"}, + "index": {"key": "index", "type": "int"}, + "node_id": {"key": "nodeId", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "mac_address": {"key": "macAddress", "type": "str"}, + "link_speed": {"key": "linkSpeed", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "rdma_status": {"key": "rdmaStatus", "type": "str"}, + "dhcp_status": {"key": "dhcpStatus", "type": "str"}, + "ipv4_configuration": {"key": "ipv4Configuration", "type": "Ipv4Config"}, + "ipv6_configuration": {"key": "ipv6Configuration", "type": "Ipv6Config"}, + "ipv6_link_local_address": {"key": "ipv6LinkLocalAddress", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, } def __init__( self, *, - rdma_status: Optional[Union[str, "NetworkAdapterRDMAStatus"]] = None, - dhcp_status: Optional[Union[str, "NetworkAdapterDHCPStatus"]] = None, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) + rdma_status: Optional[Union[str, "_models.NetworkAdapterRDMAStatus"]] = None, + dhcp_status: Optional[Union[str, "_models.NetworkAdapterDHCPStatus"]] = None, + **kwargs + ): + """ + :keyword rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :paramtype rdma_status: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterRDMAStatus + :keyword dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :paramtype dhcp_status: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkAdapterDHCPStatus + """ + super().__init__(**kwargs) self.adapter_id = None self.adapter_position = None self.index = None @@ -1562,32 +1693,30 @@ def __init__( self.dns_servers = None -class NetworkAdapterPosition(msrest.serialization.Model): +class NetworkAdapterPosition(_serialization.Model): """The network adapter position. Variables are only populated by the server, and will be ignored when sending a request. - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". + :ivar network_group: The network group. Known values are: "None", "NonRDMA", and "RDMA". :vartype network_group: str or ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkGroup :ivar port: The port. :vartype port: int """ _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, + "network_group": {"readonly": True}, + "port": {"readonly": True}, } _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, + "network_group": {"key": "networkGroup", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_group = None self.port = None @@ -1608,81 +1737,90 @@ class NetworkSettings(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "network_adapters": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "network_adapters": {"key": "properties.networkAdapters", "type": "[NetworkAdapter]"}, } - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_adapters = None -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operations. - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2019_03_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2019_03_01.models.ServiceSpecification + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties displayed for the operation. + :vartype display: ~azure.mgmt.databoxedge.v2019_03_01.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar service_specification: Service specification. + :vartype service_specification: ~azure.mgmt.databoxedge.v2019_03_01.models.ServiceSpecification """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): - super(Operation, self).__init__(**kwargs) + service_specification: Optional["_models.ServiceSpecification"] = None, + **kwargs + ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties displayed for the operation. + :paramtype display: ~azure.mgmt.databoxedge.v2019_03_01.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword service_specification: Service specification. + :paramtype service_specification: + ~azure.mgmt.databoxedge.v2019_03_01.models.ServiceSpecification + """ + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display properties. - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: The type of resource in which the operation is performed. + :vartype resource: str + :ivar operation: Operation to be performed on the resource. + :vartype operation: str + :ivar description: Description of the operation to be performed. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1694,41 +1832,51 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: The type of resource in which the operation is performed. + :paramtype resource: str + :keyword operation: Operation to be performed on the resource. + :paramtype operation: str + :keyword description: Description of the operation to be performed. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsList(msrest.serialization.Model): +class OperationsList(_serialization.Model): """The list of operations used for the discovery of available provider operations. All required parameters must be populated in order to send to Azure. - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2019_03_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar value: The value. Required. + :vartype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.Operation] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["Operation"], - next_link: Optional[str] = None, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The value. Required. + :paramtype value: list[~azure.mgmt.databoxedge.v2019_03_01.models.Operation] + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1744,12 +1892,12 @@ class Order(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2019_03_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2019_03_01.models.Address - :param current_status: Current status of the order. - :type current_status: ~azure.mgmt.databoxedge.v2019_03_01.models.OrderStatus + :ivar contact_information: The contact details. + :vartype contact_information: ~azure.mgmt.databoxedge.v2019_03_01.models.ContactDetails + :ivar shipping_address: The shipping address. + :vartype shipping_address: ~azure.mgmt.databoxedge.v2019_03_01.models.Address + :ivar current_status: Current status of the order. + :vartype current_status: ~azure.mgmt.databoxedge.v2019_03_01.models.OrderStatus :ivar order_history: List of status changes in the order. :vartype order_history: list[~azure.mgmt.databoxedge.v2019_03_01.models.OrderStatus] :ivar serial_number: Serial number of the device. @@ -1763,37 +1911,45 @@ class Order(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "order_history": {"readonly": True}, + "serial_number": {"readonly": True}, + "delivery_tracking_info": {"readonly": True}, + "return_tracking_info": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "contact_information": {"key": "properties.contactInformation", "type": "ContactDetails"}, + "shipping_address": {"key": "properties.shippingAddress", "type": "Address"}, + "current_status": {"key": "properties.currentStatus", "type": "OrderStatus"}, + "order_history": {"key": "properties.orderHistory", "type": "[OrderStatus]"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "delivery_tracking_info": {"key": "properties.deliveryTrackingInfo", "type": "[TrackingInfo]"}, + "return_tracking_info": {"key": "properties.returnTrackingInfo", "type": "[TrackingInfo]"}, } def __init__( self, *, - contact_information: Optional["ContactDetails"] = None, - shipping_address: Optional["Address"] = None, - current_status: Optional["OrderStatus"] = None, - **kwargs - ): - super(Order, self).__init__(**kwargs) + contact_information: Optional["_models.ContactDetails"] = None, + shipping_address: Optional["_models.Address"] = None, + current_status: Optional["_models.OrderStatus"] = None, + **kwargs + ): + """ + :keyword contact_information: The contact details. + :paramtype contact_information: ~azure.mgmt.databoxedge.v2019_03_01.models.ContactDetails + :keyword shipping_address: The shipping address. + :paramtype shipping_address: ~azure.mgmt.databoxedge.v2019_03_01.models.Address + :keyword current_status: Current status of the order. + :paramtype current_status: ~azure.mgmt.databoxedge.v2019_03_01.models.OrderStatus + """ + super().__init__(**kwargs) self.contact_information = contact_information self.shipping_address = shipping_address self.current_status = current_status @@ -1803,7 +1959,7 @@ def __init__( self.return_tracking_info = None -class OrderList(msrest.serialization.Model): +class OrderList(_serialization.Model): """List of order entities. Variables are only populated by the server, and will be ignored when sending a request. @@ -1815,61 +1971,62 @@ class OrderList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Order]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OrderStatus(msrest.serialization.Model): +class OrderStatus(_serialization.Model): """Represents a single status change. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft". - :type status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.OrderState + :ivar status: Status of the order as per the allowed status types. Required. Known values are: + "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", and "CollectedAtMicrosoft". + :vartype status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.OrderState :ivar update_date_time: Time of status update. :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str + :ivar comments: Comments related to this status change. + :vartype comments: str """ _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, + "status": {"required": True}, + "update_date_time": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + "comments": {"key": "comments", "type": "str"}, } - def __init__( - self, - *, - status: Union[str, "OrderState"], - comments: Optional[str] = None, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) + def __init__(self, *, status: Union[str, "_models.OrderState"], comments: Optional[str] = None, **kwargs): + """ + :keyword status: Status of the order as per the allowed status types. Required. Known values + are: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", and "CollectedAtMicrosoft". + :paramtype status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.OrderState + :keyword comments: Comments related to this status change. + :paramtype comments: str + """ + super().__init__(**kwargs) self.status = status self.update_date_time = None self.comments = comments @@ -1888,117 +2045,130 @@ class PeriodicTimerEventTrigger(Trigger): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2019_03_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2019_03_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_03_01.models.TriggerEventType + :ivar source_info: Periodic timer details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2019_03_01.models.PeriodicTimerSourceInfo + :ivar sink_info: Role Sink information. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2019_03_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "PeriodicTimerSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "PeriodicTimerSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.PeriodicTimerSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str + """ + :keyword source_info: Periodic timer details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2019_03_01.models.PeriodicTimerSourceInfo + :keyword sink_info: Role Sink information. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2019_03_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "PeriodicTimerEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class PeriodicTimerSourceInfo(msrest.serialization.Model): +class PeriodicTimerSourceInfo(_serialization.Model): """Periodic timer event source. All required parameters must be populated in order to send to Azure. - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified up to seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str + :ivar start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified up to seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :vartype start_time: ~datetime.datetime + :ivar schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :vartype schedule: str + :ivar topic: Topic where periodic events are published to IoT device. + :vartype topic: str """ _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, + "start_time": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "schedule": {"key": "schedule", "type": "str"}, + "topic": {"key": "topic", "type": "str"}, } - def __init__( - self, - *, - start_time: datetime.datetime, - schedule: str, - topic: Optional[str] = None, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) + def __init__(self, *, start_time: datetime.datetime, schedule: str, topic: Optional[str] = None, **kwargs): + """ + :keyword start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified up to seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :paramtype start_time: ~datetime.datetime + :keyword schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :paramtype schedule: str + :keyword topic: Topic where periodic events are published to IoT device. + :paramtype topic: str + """ + super().__init__(**kwargs) self.start_time = start_time self.schedule = schedule self.topic = topic -class RefreshDetails(msrest.serialization.Model): +class RefreshDetails(_serialization.Model): """Fields for tracking refresh job on the share. - :param in_progress_refresh_job_id: If a refresh share job is currently in progress on this + :ivar in_progress_refresh_job_id: If a refresh share job is currently in progress on this share, this field indicates the ARM resource ID of that job. The field is empty if no job is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share, if any.This could be a failed job or a successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh + :vartype in_progress_refresh_job_id: str + :ivar last_completed_refresh_job_time_in_utc: Indicates the completed time for the last refresh + job on this particular share, if any.This could be a failed job or a successful job. + :vartype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :ivar error_manifest_file: Indicates the relative path of the error xml for the last refresh job on this particular share, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share,if any. This + :vartype error_manifest_file: str + :ivar last_job: Indicates the id of the last refresh job on this particular share,if any. This could be a failed job or a successful job. - :type last_job: str + :vartype last_job: str """ _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, + "in_progress_refresh_job_id": {"key": "inProgressRefreshJobId", "type": "str"}, + "last_completed_refresh_job_time_in_utc": {"key": "lastCompletedRefreshJobTimeInUTC", "type": "iso-8601"}, + "error_manifest_file": {"key": "errorManifestFile", "type": "str"}, + "last_job": {"key": "lastJob", "type": "str"}, } def __init__( @@ -2010,14 +2180,29 @@ def __init__( last_job: Optional[str] = None, **kwargs ): - super(RefreshDetails, self).__init__(**kwargs) + """ + :keyword in_progress_refresh_job_id: If a refresh share job is currently in progress on this + share, this field indicates the ARM resource ID of that job. The field is empty if no job is in + progress. + :paramtype in_progress_refresh_job_id: str + :keyword last_completed_refresh_job_time_in_utc: Indicates the completed time for the last + refresh job on this particular share, if any.This could be a failed job or a successful job. + :paramtype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :keyword error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share, if any. This could be a failed job or a successful job. + :paramtype error_manifest_file: str + :keyword last_job: Indicates the id of the last refresh job on this particular share,if any. + This could be a failed job or a successful job. + :paramtype last_job: str + """ + super().__init__(**kwargs) self.in_progress_refresh_job_id = in_progress_refresh_job_id self.last_completed_refresh_job_time_in_utc = last_completed_refresh_job_time_in_utc self.error_manifest_file = error_manifest_file self.last_job = last_job -class RoleList(msrest.serialization.Model): +class RoleList(_serialization.Model): """Collection of all the roles on the Data Box Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2029,48 +2214,45 @@ class RoleList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Role]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RoleSinkInfo(msrest.serialization.Model): +class RoleSinkInfo(_serialization.Model): """Compute role against which events will be raised. All required parameters must be populated in order to send to Azure. - :param role_id: Required. Compute role ID. - :type role_id: str + :ivar role_id: Compute role ID. Required. + :vartype role_id: str """ _validation = { - 'role_id': {'required': True}, + "role_id": {"required": True}, } _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, + "role_id": {"key": "roleId", "type": "str"}, } - def __init__( - self, - *, - role_id: str, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) + def __init__(self, *, role_id: str, **kwargs): + """ + :keyword role_id: Compute role ID. Required. + :paramtype role_id: str + """ + super().__init__(**kwargs) self.role_id = role_id @@ -2087,61 +2269,64 @@ class SecuritySettings(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: + :ivar device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :vartype device_admin_password: ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "device_admin_password": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_admin_password": {"key": "properties.deviceAdminPassword", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - device_admin_password: "AsymmetricEncryptedSecret", - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) + def __init__(self, *, device_admin_password: "_models.AsymmetricEncryptedSecret", **kwargs): + """ + :keyword device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :paramtype device_admin_password: + ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.device_admin_password = device_admin_password -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification. - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: + :ivar metric_specifications: Metric specification as defined by shoebox. + :vartype metric_specifications: list[~azure.mgmt.databoxedge.v2019_03_01.models.MetricSpecificationV1] """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecificationV1]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["MetricSpecificationV1"]] = None, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecificationV1"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specification as defined by shoebox. + :paramtype metric_specifications: + list[~azure.mgmt.databoxedge.v2019_03_01.models.MetricSpecificationV1] + """ + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Share(ARMBaseModel): +class Share(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Represents a share on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2154,74 +2339,103 @@ class Share(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Online", + :ivar description: Description for the share. + :vartype description: str + :ivar share_status: Current status of the share. Required. Known values are: "Online" and "Offline". - :type share_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2019_03_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share + :vartype share_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareStatus + :ivar monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :vartype monitoring_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.MonitoringStatus + :ivar azure_container_info: Azure container mapping for the share. + :vartype azure_container_info: ~azure.mgmt.databoxedge.v2019_03_01.models.AzureContainerInfo + :ivar access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :vartype access_protocol: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessProtocol + :ivar user_access_rights: Mapping of users and corresponding access rights on the share (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2019_03_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the + :vartype user_access_rights: list[~azure.mgmt.databoxedge.v2019_03_01.models.UserAccessRight] + :ivar client_access_rights: List of IP addresses and corresponding access rights on the share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2019_03_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2019_03_01.models.RefreshDetails + :vartype client_access_rights: + list[~azure.mgmt.databoxedge.v2019_03_01.models.ClientAccessRight] + :ivar refresh_details: Details of the refresh job on this share. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2019_03_01.models.RefreshDetails :ivar share_mappings: Share mount point to the role. :vartype share_mappings: list[~azure.mgmt.databoxedge.v2019_03_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2019_03_01.models.DataPolicy + :ivar data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2019_03_01.models.DataPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "share_status": {"required": True}, + "monitoring_status": {"required": True}, + "access_protocol": {"required": True}, + "share_mappings": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "share_status": {"key": "properties.shareStatus", "type": "str"}, + "monitoring_status": {"key": "properties.monitoringStatus", "type": "str"}, + "azure_container_info": {"key": "properties.azureContainerInfo", "type": "AzureContainerInfo"}, + "access_protocol": {"key": "properties.accessProtocol", "type": "str"}, + "user_access_rights": {"key": "properties.userAccessRights", "type": "[UserAccessRight]"}, + "client_access_rights": {"key": "properties.clientAccessRights", "type": "[ClientAccessRight]"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, } def __init__( self, *, - share_status: Union[str, "ShareStatus"], - monitoring_status: Union[str, "MonitoringStatus"], - access_protocol: Union[str, "ShareAccessProtocol"], + share_status: Union[str, "_models.ShareStatus"], + monitoring_status: Union[str, "_models.MonitoringStatus"], + access_protocol: Union[str, "_models.ShareAccessProtocol"], description: Optional[str] = None, - azure_container_info: Optional["AzureContainerInfo"] = None, - user_access_rights: Optional[List["UserAccessRight"]] = None, - client_access_rights: Optional[List["ClientAccessRight"]] = None, - refresh_details: Optional["RefreshDetails"] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, - **kwargs - ): - super(Share, self).__init__(**kwargs) + azure_container_info: Optional["_models.AzureContainerInfo"] = None, + user_access_rights: Optional[List["_models.UserAccessRight"]] = None, + client_access_rights: Optional[List["_models.ClientAccessRight"]] = None, + refresh_details: Optional["_models.RefreshDetails"] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, + **kwargs + ): + """ + :keyword description: Description for the share. + :paramtype description: str + :keyword share_status: Current status of the share. Required. Known values are: "Online" and + "Offline". + :paramtype share_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareStatus + :keyword monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :paramtype monitoring_status: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.MonitoringStatus + :keyword azure_container_info: Azure container mapping for the share. + :paramtype azure_container_info: ~azure.mgmt.databoxedge.v2019_03_01.models.AzureContainerInfo + :keyword access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :paramtype access_protocol: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessProtocol + :keyword user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :paramtype user_access_rights: list[~azure.mgmt.databoxedge.v2019_03_01.models.UserAccessRight] + :keyword client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :paramtype client_access_rights: + list[~azure.mgmt.databoxedge.v2019_03_01.models.ClientAccessRight] + :keyword refresh_details: Details of the refresh job on this share. + :paramtype refresh_details: ~azure.mgmt.databoxedge.v2019_03_01.models.RefreshDetails + :keyword data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2019_03_01.models.DataPolicy + """ + super().__init__(**kwargs) self.description = description self.share_status = share_status self.monitoring_status = monitoring_status @@ -2234,41 +2448,42 @@ def __init__( self.data_policy = data_policy -class ShareAccessRight(msrest.serialization.Model): +class ShareAccessRight(_serialization.Model): """Specifies the mapping between this particular user and the type of access he has on shares on this device. All required parameters must be populated in order to send to Azure. - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessType + :ivar share_id: The share ID. Required. + :vartype share_id: str + :ivar access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessType """ _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, + "share_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) + def __init__(self, *, share_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword share_id: The share ID. Required. + :paramtype share_id: str + :keyword access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.share_id = share_id self.access_type = access_type -class ShareList(msrest.serialization.Model): +class ShareList(_serialization.Model): """Collection of all the shares on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2280,46 +2495,50 @@ class ShareList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Share]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU type. - :param name: SKU name. Possible values include: "Gateway", "Edge". - :type name: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SkuTier + :ivar name: SKU name. Known values are: "Gateway" and "Edge". + :vartype name: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SkuTier """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "SkuName"]] = None, - tier: Optional[Union[str, "SkuTier"]] = None, + name: Optional[Union[str, "_models.SkuName"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, **kwargs ): - super(Sku, self).__init__(**kwargs) + """ + :keyword name: SKU name. Known values are: "Gateway" and "Edge". + :paramtype name: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SkuName + :keyword tier: The SKU tier. This is based on the SKU name. "Standard" + :paramtype tier: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SkuTier + """ + super().__init__(**kwargs) self.name = name self.tier = tier @@ -2337,60 +2556,79 @@ class StorageAccountCredential(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AccountType + :ivar alias: Alias for the storage account. Required. + :vartype alias: str + :ivar user_name: Username for the storage account. + :vartype user_name: str + :ivar account_key: Encrypted storage key. + :vartype account_key: ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string for the storage account. Use this string if username + and account key are not specified. + :vartype connection_string: str + :ivar ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values are: + "Enabled" and "Disabled". + :vartype ssl_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SSLStatus + :ivar blob_domain_name: Blob end point for private clouds. + :vartype blob_domain_name: str + :ivar account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :vartype account_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AccountType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "alias": {"required": True}, + "ssl_status": {"required": True}, + "account_type": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "alias": {"key": "properties.alias", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "account_key": {"key": "properties.accountKey", "type": "AsymmetricEncryptedSecret"}, + "connection_string": {"key": "properties.connectionString", "type": "str"}, + "ssl_status": {"key": "properties.sslStatus", "type": "str"}, + "blob_domain_name": {"key": "properties.blobDomainName", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, } def __init__( self, *, alias: str, - ssl_status: Union[str, "SSLStatus"], - account_type: Union[str, "AccountType"], + ssl_status: Union[str, "_models.SSLStatus"], + account_type: Union[str, "_models.AccountType"], user_name: Optional[str] = None, - account_key: Optional["AsymmetricEncryptedSecret"] = None, + account_key: Optional["_models.AsymmetricEncryptedSecret"] = None, connection_string: Optional[str] = None, blob_domain_name: Optional[str] = None, **kwargs ): - super(StorageAccountCredential, self).__init__(**kwargs) + """ + :keyword alias: Alias for the storage account. Required. + :paramtype alias: str + :keyword user_name: Username for the storage account. + :paramtype user_name: str + :keyword account_key: Encrypted storage key. + :paramtype account_key: ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret + :keyword connection_string: Connection string for the storage account. Use this string if + username and account key are not specified. + :paramtype connection_string: str + :keyword ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values + are: "Enabled" and "Disabled". + :paramtype ssl_status: str or ~azure.mgmt.databoxedge.v2019_03_01.models.SSLStatus + :keyword blob_domain_name: Blob end point for private clouds. + :paramtype blob_domain_name: str + :keyword account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :paramtype account_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AccountType + """ + super().__init__(**kwargs) self.alias = alias self.user_name = user_name self.account_key = account_key @@ -2400,7 +2638,7 @@ def __init__( self.account_type = account_type -class StorageAccountCredentialList(msrest.serialization.Model): +class StorageAccountCredentialList(_serialization.Model): """The collection of storage account credentials. Variables are only populated by the server, and will be ignored when sending a request. @@ -2412,63 +2650,62 @@ class StorageAccountCredentialList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccountCredential]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SymmetricKey(msrest.serialization.Model): +class SymmetricKey(_serialization.Model): """Symmetric key for authentication. - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string based on the symmetric key. + :vartype connection_string: + ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret """ _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, + "connection_string": {"key": "connectionString", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) + def __init__(self, *, connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs): + """ + :keyword connection_string: Connection string based on the symmetric key. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.connection_string = connection_string -class TrackingInfo(msrest.serialization.Model): +class TrackingInfo(_serialization.Model): """Tracking courier information. - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str + :ivar serial_number: Serial number of the device being tracked. + :vartype serial_number: str + :ivar carrier_name: Name of the carrier used in the delivery. + :vartype carrier_name: str + :ivar tracking_id: Tracking ID of the shipment. + :vartype tracking_id: str + :ivar tracking_url: Tracking URL of the shipment. + :vartype tracking_url: str """ _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, + "serial_number": {"key": "serialNumber", "type": "str"}, + "carrier_name": {"key": "carrierName", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "tracking_url": {"key": "trackingUrl", "type": "str"}, } def __init__( @@ -2480,14 +2717,24 @@ def __init__( tracking_url: Optional[str] = None, **kwargs ): - super(TrackingInfo, self).__init__(**kwargs) + """ + :keyword serial_number: Serial number of the device being tracked. + :paramtype serial_number: str + :keyword carrier_name: Name of the carrier used in the delivery. + :paramtype carrier_name: str + :keyword tracking_id: Tracking ID of the shipment. + :paramtype tracking_id: str + :keyword tracking_url: Tracking URL of the shipment. + :paramtype tracking_url: str + """ + super().__init__(**kwargs) self.serial_number = serial_number self.carrier_name = carrier_name self.tracking_id = tracking_id self.tracking_url = tracking_url -class TriggerList(msrest.serialization.Model): +class TriggerList(_serialization.Model): """Collection of all trigger on the data box edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2499,31 +2746,29 @@ class TriggerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Trigger]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class UpdateDownloadProgress(msrest.serialization.Model): +class UpdateDownloadProgress(_serialization.Model): """Details about the download progress of update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". + :ivar download_phase: The download phase. Known values are: "Unknown", "Initializing", + "Downloading", and "Verifying". :vartype download_phase: str or ~azure.mgmt.databoxedge.v2019_03_01.models.DownloadPhase :ivar percent_complete: Percentage of completion. :vartype percent_complete: int @@ -2538,28 +2783,26 @@ class UpdateDownloadProgress(msrest.serialization.Model): """ _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, + "download_phase": {"readonly": True}, + "percent_complete": {"readonly": True}, + "total_bytes_to_download": {"readonly": True}, + "total_bytes_downloaded": {"readonly": True}, + "number_of_updates_to_download": {"readonly": True}, + "number_of_updates_downloaded": {"readonly": True}, } _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, + "download_phase": {"key": "downloadPhase", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "total_bytes_to_download": {"key": "totalBytesToDownload", "type": "float"}, + "total_bytes_downloaded": {"key": "totalBytesDownloaded", "type": "float"}, + "number_of_updates_to_download": {"key": "numberOfUpdatesToDownload", "type": "int"}, + "number_of_updates_downloaded": {"key": "numberOfUpdatesDownloaded", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.download_phase = None self.percent_complete = None self.total_bytes_to_download = None @@ -2568,7 +2811,7 @@ def __init__( self.number_of_updates_downloaded = None -class UpdateInstallProgress(msrest.serialization.Model): +class UpdateInstallProgress(_serialization.Model): """Progress details during installation of updates. Variables are only populated by the server, and will be ignored when sending a request. @@ -2582,28 +2825,26 @@ class UpdateInstallProgress(msrest.serialization.Model): """ _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, + "percent_complete": {"readonly": True}, + "number_of_updates_to_install": {"readonly": True}, + "number_of_updates_installed": {"readonly": True}, } _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "number_of_updates_to_install": {"key": "numberOfUpdatesToInstall", "type": "int"}, + "number_of_updates_installed": {"key": "numberOfUpdatesInstalled", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.percent_complete = None self.number_of_updates_to_install = None self.number_of_updates_installed = None -class UpdateSummary(ARMBaseModel): +class UpdateSummary(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Details about ongoing updates and availability of updates on the device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2614,15 +2855,15 @@ class UpdateSummary(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed + :ivar device_version_number: The current version of the device in format: 1.2.17312.13.",. + :vartype device_version_number: str + :ivar friendly_device_version_name: The current version of the device in text format. + :vartype friendly_device_version_name: str + :ivar device_last_scanned_date_time: The last time when a scan was done on the device. + :vartype device_last_scanned_date_time: ~datetime.datetime + :ivar last_completed_scan_job_date_time: The time when the last scan job was completed (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime + :vartype last_completed_scan_job_date_time: ~datetime.datetime :ivar last_completed_download_job_date_time: The time when the last Download job was completed (success/cancelled/failed) on the appliance. :vartype last_completed_download_job_date_time: ~datetime.datetime @@ -2637,11 +2878,11 @@ class UpdateSummary(ARMBaseModel): :ivar total_number_of_updates_pending_install: The total number of items pending install. :vartype total_number_of_updates_pending_install: int :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.databoxedge.v2019_03_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". + :ivar ongoing_update_operation: The current update operation. Known values are: "None", "Scan", + "Download", and "Install". :vartype ongoing_update_operation: str or ~azure.mgmt.databoxedge.v2019_03_01.models.UpdateOperation :ivar in_progress_download_job_id: The job ID of the download job in progress. @@ -2661,45 +2902,63 @@ class UpdateSummary(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_completed_download_job_date_time": {"readonly": True}, + "last_completed_install_job_date_time": {"readonly": True}, + "total_number_of_updates_available": {"readonly": True}, + "total_number_of_updates_pending_download": {"readonly": True}, + "total_number_of_updates_pending_install": {"readonly": True}, + "reboot_behavior": {"readonly": True}, + "ongoing_update_operation": {"readonly": True}, + "in_progress_download_job_id": {"readonly": True}, + "in_progress_install_job_id": {"readonly": True}, + "in_progress_download_job_started_date_time": {"readonly": True}, + "in_progress_install_job_started_date_time": {"readonly": True}, + "update_titles": {"readonly": True}, + "total_update_size_in_bytes": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_version_number": {"key": "properties.deviceVersionNumber", "type": "str"}, + "friendly_device_version_name": {"key": "properties.friendlyDeviceVersionName", "type": "str"}, + "device_last_scanned_date_time": {"key": "properties.deviceLastScannedDateTime", "type": "iso-8601"}, + "last_completed_scan_job_date_time": {"key": "properties.lastCompletedScanJobDateTime", "type": "iso-8601"}, + "last_completed_download_job_date_time": { + "key": "properties.lastCompletedDownloadJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_date_time": { + "key": "properties.lastCompletedInstallJobDateTime", + "type": "iso-8601", + }, + "total_number_of_updates_available": {"key": "properties.totalNumberOfUpdatesAvailable", "type": "int"}, + "total_number_of_updates_pending_download": { + "key": "properties.totalNumberOfUpdatesPendingDownload", + "type": "int", + }, + "total_number_of_updates_pending_install": { + "key": "properties.totalNumberOfUpdatesPendingInstall", + "type": "int", + }, + "reboot_behavior": {"key": "properties.rebootBehavior", "type": "str"}, + "ongoing_update_operation": {"key": "properties.ongoingUpdateOperation", "type": "str"}, + "in_progress_download_job_id": {"key": "properties.inProgressDownloadJobId", "type": "str"}, + "in_progress_install_job_id": {"key": "properties.inProgressInstallJobId", "type": "str"}, + "in_progress_download_job_started_date_time": { + "key": "properties.inProgressDownloadJobStartedDateTime", + "type": "iso-8601", + }, + "in_progress_install_job_started_date_time": { + "key": "properties.inProgressInstallJobStartedDateTime", + "type": "iso-8601", + }, + "update_titles": {"key": "properties.updateTitles", "type": "[str]"}, + "total_update_size_in_bytes": {"key": "properties.totalUpdateSizeInBytes", "type": "float"}, } def __init__( @@ -2711,7 +2970,18 @@ def __init__( last_completed_scan_job_date_time: Optional[datetime.datetime] = None, **kwargs ): - super(UpdateSummary, self).__init__(**kwargs) + """ + :keyword device_version_number: The current version of the device in format: 1.2.17312.13.",. + :paramtype device_version_number: str + :keyword friendly_device_version_name: The current version of the device in text format. + :paramtype friendly_device_version_name: str + :keyword device_last_scanned_date_time: The last time when a scan was done on the device. + :paramtype device_last_scanned_date_time: ~datetime.datetime + :keyword last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :paramtype last_completed_scan_job_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.device_version_number = device_version_number self.friendly_device_version_name = friendly_device_version_name self.device_last_scanned_date_time = device_last_scanned_date_time @@ -2731,80 +3001,89 @@ def __init__( self.total_update_size_in_bytes = None -class UploadCertificateRequest(msrest.serialization.Model): +class UploadCertificateRequest(_serialization.Model): """The upload certificate request. All required parameters must be populated in order to send to Azure. - :param authentication_type: The authentication type. Possible values include: "Invalid", + :ivar authentication_type: The authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str + :vartype authentication_type: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.AuthenticationType + :ivar certificate: The base64 encoded certificate raw data. Required. + :vartype certificate: str """ _validation = { - 'certificate': {'required': True}, + "certificate": {"required": True}, } _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "certificate": {"key": "properties.certificate", "type": "str"}, } def __init__( self, *, certificate: str, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + **kwargs + ): + """ + :keyword authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype authentication_type: str or + ~azure.mgmt.databoxedge.v2019_03_01.models.AuthenticationType + :keyword certificate: The base64 encoded certificate raw data. Required. + :paramtype certificate: str + """ + super().__init__(**kwargs) self.authentication_type = authentication_type self.certificate = certificate -class UploadCertificateResponse(msrest.serialization.Model): +class UploadCertificateResponse(_serialization.Model): """The upload registration certificate response. All required parameters must be populated in order to send to Azure. - :param auth_type: Specifies authentication type. Possible values include: "Invalid", + :ivar auth_type: Specifies authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AuthenticationType - :param resource_id: Required. The resource ID of the Data Box Edge/Gateway device. - :type resource_id: str - :param aad_authority: Required. Azure Active Directory tenant authority. - :type aad_authority: str - :param aad_tenant_id: Required. Azure Active Directory tenant ID. - :type aad_tenant_id: str - :param service_principal_client_id: Required. Azure Active Directory service principal client - ID. - :type service_principal_client_id: str - :param service_principal_object_id: Required. Azure Active Directory service principal object - ID. - :type service_principal_object_id: str - :param azure_management_endpoint_audience: Required. The azure management endpoint audience. - :type azure_management_endpoint_audience: str + :vartype auth_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AuthenticationType + :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. Required. + :vartype resource_id: str + :ivar aad_authority: Azure Active Directory tenant authority. Required. + :vartype aad_authority: str + :ivar aad_tenant_id: Azure Active Directory tenant ID. Required. + :vartype aad_tenant_id: str + :ivar service_principal_client_id: Azure Active Directory service principal client ID. + Required. + :vartype service_principal_client_id: str + :ivar service_principal_object_id: Azure Active Directory service principal object ID. + Required. + :vartype service_principal_object_id: str + :ivar azure_management_endpoint_audience: The azure management endpoint audience. Required. + :vartype azure_management_endpoint_audience: str """ _validation = { - 'resource_id': {'required': True}, - 'aad_authority': {'required': True}, - 'aad_tenant_id': {'required': True}, - 'service_principal_client_id': {'required': True}, - 'service_principal_object_id': {'required': True}, - 'azure_management_endpoint_audience': {'required': True}, + "resource_id": {"required": True}, + "aad_authority": {"required": True}, + "aad_tenant_id": {"required": True}, + "service_principal_client_id": {"required": True}, + "service_principal_object_id": {"required": True}, + "azure_management_endpoint_audience": {"required": True}, } _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, + "auth_type": {"key": "authType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "aad_authority": {"key": "aadAuthority", "type": "str"}, + "aad_tenant_id": {"key": "aadTenantId", "type": "str"}, + "service_principal_client_id": {"key": "servicePrincipalClientId", "type": "str"}, + "service_principal_object_id": {"key": "servicePrincipalObjectId", "type": "str"}, + "azure_management_endpoint_audience": {"key": "azureManagementEndpointAudience", "type": "str"}, } def __init__( @@ -2816,10 +3095,29 @@ def __init__( service_principal_client_id: str, service_principal_object_id: str, azure_management_endpoint_audience: str, - auth_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) + auth_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + **kwargs + ): + """ + :keyword auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype auth_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.AuthenticationType + :keyword resource_id: The resource ID of the Data Box Edge/Gateway device. Required. + :paramtype resource_id: str + :keyword aad_authority: Azure Active Directory tenant authority. Required. + :paramtype aad_authority: str + :keyword aad_tenant_id: Azure Active Directory tenant ID. Required. + :paramtype aad_tenant_id: str + :keyword service_principal_client_id: Azure Active Directory service principal client ID. + Required. + :paramtype service_principal_client_id: str + :keyword service_principal_object_id: Azure Active Directory service principal object ID. + Required. + :paramtype service_principal_object_id: str + :keyword azure_management_endpoint_audience: The azure management endpoint audience. Required. + :paramtype azure_management_endpoint_audience: str + """ + super().__init__(**kwargs) self.auth_type = auth_type self.resource_id = resource_id self.aad_authority = aad_authority @@ -2840,74 +3138,85 @@ class User(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret - :param share_access_rights: List of shares that the user has rights on. This field should not - be specified during user creation. - :type share_access_rights: list[~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessRight] + :ivar encrypted_password: The password details. + :vartype encrypted_password: + ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret + :ivar share_access_rights: List of shares that the user has rights on. This field should not be + specified during user creation. + :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessRight] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encrypted_password": {"key": "properties.encryptedPassword", "type": "AsymmetricEncryptedSecret"}, + "share_access_rights": {"key": "properties.shareAccessRights", "type": "[ShareAccessRight]"}, } def __init__( self, *, - encrypted_password: Optional["AsymmetricEncryptedSecret"] = None, - share_access_rights: Optional[List["ShareAccessRight"]] = None, - **kwargs - ): - super(User, self).__init__(**kwargs) + encrypted_password: Optional["_models.AsymmetricEncryptedSecret"] = None, + share_access_rights: Optional[List["_models.ShareAccessRight"]] = None, + **kwargs + ): + """ + :keyword encrypted_password: The password details. + :paramtype encrypted_password: + ~azure.mgmt.databoxedge.v2019_03_01.models.AsymmetricEncryptedSecret + :keyword share_access_rights: List of shares that the user has rights on. This field should not + be specified during user creation. + :paramtype share_access_rights: + list[~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessRight] + """ + super().__init__(**kwargs) self.encrypted_password = encrypted_password self.share_access_rights = share_access_rights -class UserAccessRight(msrest.serialization.Model): +class UserAccessRight(_serialization.Model): """The mapping between a particular user and the access type on the SMB share. All required parameters must be populated in order to send to Azure. - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessType + :ivar user_id: User ID (already existing in the device). Required. + :vartype user_id: str + :ivar access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessType """ _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, + "user_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, + "user_id": {"key": "userId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, } - def __init__( - self, - *, - user_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) + def __init__(self, *, user_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword user_id: User ID (already existing in the device). Required. + :paramtype user_id: str + :keyword access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2019_03_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.user_id = user_id self.access_type = access_type -class UserList(msrest.serialization.Model): +class UserList(_serialization.Model): """Collection of users. Variables are only populated by the server, and will be ignored when sending a request. @@ -2919,19 +3228,17 @@ class UserList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[User]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/__init__.py index f1ff40408d10..49f127f3253c 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/__init__.py @@ -19,17 +19,23 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_alerts_operations.py index 23704e68521d..afb6a34f270e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class AlertsOperations(object): - """AlertsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_by_data_box_edge_device_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Alert"]: """Gets all the alerts for a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,72 +206,73 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_bandwidth_schedules_operations.py index fb1ea0ce78d2..3dcd62405aec 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,268 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class BandwidthSchedulesOperations(object): - """BandwidthSchedulesOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BandwidthSchedulesList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +276,126 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BandwidthSchedule" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BandwidthSchedule"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +404,215 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BandwidthSchedule"] + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +622,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_devices_operations.py index eafcd638a8ef..f0bc993d3adf 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,581 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", + ) # 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"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_download_updates_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_extended_information_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_install_updates_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_settings_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_scan_for_updates_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_security_settings_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class DevicesOperations(object): - """DevicesOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_update_summary_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_upload_certificate_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_subscription( - self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the data box edge/gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,75 +589,90 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + @distributed_trace def list_by_resource_group( - self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the data box edge/gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,230 +681,325 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } def _create_or_update_initial( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -425,174 +1009,243 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def update( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDevicePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - def _download_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -602,168 +1255,170 @@ def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } - def begin_download_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_download_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Downloads the updates on a data box edge/gateway device. Downloads the updates on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._download_updates_initial( + raw_result = self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace def get_extended_information( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - def _install_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -773,168 +1428,170 @@ def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } - def begin_install_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_install_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Installs the updates on the data box edge/gateway device. Installs the updates on the data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._install_updates_initial( + raw_result = self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace def get_network_settings( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkSettings" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - def _scan_for_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -944,115 +1601,124 @@ def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def begin_scan_for_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_scan_for_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Scans for updates on a data box edge/gateway device. Scans for updates on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._scan_for_updates_initial( + raw_result = self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def _create_or_update_security_settings_initial( + def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1062,202 +1728,353 @@ def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload def begin_create_or_update_security_settings( self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the security settings on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2019_03_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a data box edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a data box edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2019_03_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_security_settings_initial( + raw_result = self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def get_update_summary( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateSummary" - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @distributed_trace + def get_update_summary(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload def upload_certificate( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.UploadCertificateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.UploadCertificateResponse" + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_jobs_operations.py index 425a366cf4bd..807a5e26f983 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class JobsOperations(object): - """JobsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a data box edge/gateway device. Gets the details of a specified job on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_operations.py index a12f6aa1e7c9..fd221114327e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") -class Operations(object): - """Operations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataBoxEdge/operations") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +155,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_operations_status_operations.py index 57e5cb8d66d0..3fff1713d538 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class OperationsStatusOperations(object): - """OperationsStatusOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a data box edge/gateway device. Gets the details of a specified job on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_orders_operations.py index 6227f5ccf7f1..21eccf0762ab 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,264 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request(device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class OrdersOperations(object): - """OrdersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OrderList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Order"]: """Lists all the orders related to a data box edge/gateway device. Lists all the orders related to a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,112 +272,119 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Order" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } def _create_or_update_initial( - self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Order"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,122 +393,200 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Order"] + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2019_03_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2019_03_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,71 +596,71 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_roles_operations.py index afb182c9818e..0a26e356a3e5 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,267 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class RolesOperations(object): - """RolesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Role"]: """Lists all the roles configured in a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +275,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Role" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Role"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +398,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Role"] + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2019_03_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2019_03_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +604,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the role on the data box edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_shares_operations.py index 294c68068676..c3287062f708 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,301 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_delete_request( + device_name: str, name: str, 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 {}) -class SharesOperations(object): - """SharesOperations operations. + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ShareList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Share"]: """Lists all the shares in a data box edge/gateway device. Lists all the shares in a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +309,123 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Share" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Share"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +434,209 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Share"] + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2019_03_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2019_03_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,114 +646,110 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the share on the data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -488,76 +759,74 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } - def begin_refresh( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_refresh(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_storage_account_credentials_operations.py index 869e22514f35..e8af3548040a 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,271 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class StorageAccountCredentialsOperations(object): - """StorageAccountCredentialsOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountCredentialList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a data box edge/gateway device. Gets all the storage account credentials in a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,116 +279,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountCredential" + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccountCredential"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -237,127 +409,217 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccountCredential"] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -367,74 +629,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_triggers_operations.py index 269bedf97869..e8960175ce50 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,273 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class TriggersOperations(object): - """TriggersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TriggerList"] + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +281,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Trigger" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Trigger"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,127 +404,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Trigger"] + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2019_03_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Trigger or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2019_03_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +610,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_users_operations.py index e990e85a43cd..ffaaa92f43b1 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_03_01/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,267 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class UsersOperations(object): - """UsersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_03_01.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.User"]: """Gets all the users registered on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 UserList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_03_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +275,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_03_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.User"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +398,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.User"] + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: """Creates a new user or updates an existing user's information on a data box edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2019_03_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a data box edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a data box edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2019_03_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_03_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +604,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/__init__.py index e63196b6b98f..d2bcf6a47896 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/__init__.py @@ -7,10 +7,20 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_configuration.py index e224a4c88390..54b3124084ea 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_configuration.py @@ -6,65 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", "2019-07-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-07-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_data_box_edge_management_client.py index b6bdb6e27a72..5f9d5f4fa5cc 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_data_box_edge_management_client.py @@ -6,36 +6,37 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AlertsOperations, + BandwidthSchedulesOperations, + DevicesOperations, + JobsOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from . import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations @@ -45,13 +46,15 @@ class DataBoxEdgeManagementClient(object): :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2019_07_01.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2019_07_01.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2019_07_01.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2019_07_01.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2019_07_01.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2019_07_01.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2019_07_01.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2019_07_01.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -59,91 +62,89 @@ class DataBoxEdgeManagementClient(object): :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2019_07_01.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2019_07_01.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2019_07_01.operations.StorageAccountCredentialsOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2019_07_01.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2019_07_01.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._client, self._config, self._serialize, self._deserialize + ) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None + + 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) -> None: self._client.close() - def __enter__(self): - # type: () -> DataBoxEdgeManagementClient + def __enter__(self) -> "DataBoxEdgeManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_metadata.json b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_metadata.json index 8880d13820a0..bd3717f02227 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_metadata.json +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_metadata.json @@ -5,25 +5,25 @@ "name": "DataBoxEdgeManagementClient", "filename": "_data_box_edge_management_client", "description": "The DataBoxEdge Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription ID.", + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription ID.", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=None, # type: Optional[str]", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -112,4 +111,4 @@ "triggers": "TriggersOperations", "users": "UsersOperations" } -} \ No newline at end of file +} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_vendor.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_version.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/__init__.py index c33d46ee91d8..fcb8775eaa10 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_configuration.py index a741729c4134..c9147a3552a6 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_configuration.py @@ -6,61 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", "2019-07-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-07-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_data_box_edge_management_client.py index 646214481c40..09f20147ce9f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_data_box_edge_management_client.py @@ -6,34 +6,37 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AlertsOperations, + BandwidthSchedulesOperations, + DevicesOperations, + JobsOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .. import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations @@ -43,13 +46,15 @@ class DataBoxEdgeManagementClient(object): :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2019_07_01.aio.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2019_07_01.aio.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2019_07_01.aio.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2019_07_01.aio.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2019_07_01.aio.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2019_07_01.aio.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2019_07_01.aio.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2019_07_01.aio.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -57,79 +62,82 @@ class DataBoxEdgeManagementClient(object): :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2019_07_01.aio.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2019_07_01.aio.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2019_07_01.aio.operations.StorageAccountCredentialsOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2019_07_01.aio.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2019_07_01.aio.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/__init__.py index 6d25b62f30f7..b9103503dff3 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/__init__.py @@ -20,18 +20,24 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_alerts_operations.py index 63b2fd3d1975..785ba507d43b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._alerts_operations import build_get_request, build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AlertsOperations: - """AlertsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AlertList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,71 +142,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Alert": + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_bandwidth_schedules_operations.py index 4206112163f5..88d416fb5302 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._bandwidth_schedules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BandwidthSchedulesOperations: - """BandwidthSchedulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.BandwidthSchedulesList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.BandwidthSchedule": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> Optional["_models.BandwidthSchedule"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +279,215 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> AsyncLROPoller["_models.BandwidthSchedule"]: + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +497,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_devices_operations.py index 3c9dbd934fa3..7e072d95468e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._devices_operations import ( + build_create_or_update_request, + build_create_or_update_security_settings_request, + build_delete_request, + build_download_updates_request, + build_get_extended_information_request, + build_get_network_settings_request, + build_get_request, + build_get_update_summary_request, + build_install_updates_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_scan_for_updates_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations: - """DevicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_subscription( - self, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,74 +158,90 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,226 +250,325 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDevice": + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } async def _create_or_update_initial( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> "_models.DataBoxEdgeDevice": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> AsyncLROPoller["_models.DataBoxEdgeDevice"]: + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -415,171 +578,243 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload async def update( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDevicePatch", - **kwargs - ) -> "_models.DataBoxEdgeDevice": + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - async def _download_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -589,165 +824,172 @@ async def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def begin_download_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._download_updates_initial( + raw_result = await self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace_async async def get_extended_information( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - async def _install_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + async def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -757,165 +999,172 @@ async def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def begin_install_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._install_updates_initial( + raw_result = await self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def get_network_settings( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.NetworkSettings": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - async def _scan_for_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + async def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -925,113 +1174,126 @@ async def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + @distributed_trace_async async def begin_scan_for_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._scan_for_updates_initial( + raw_result = await self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _create_or_update_security_settings_initial( + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + + async def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1041,199 +1303,355 @@ async def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload async def begin_create_or_update_security_settings( self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2019_07_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2019_07_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_security_settings_initial( + raw_result = await self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @distributed_trace_async async def get_update_summary( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.UpdateSummary": - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload async def upload_certificate( self, device_name: str, resource_group_name: str, - parameters: "_models.UploadCertificateRequest", - **kwargs - ) -> "_models.UploadCertificateResponse": + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_jobs_operations.py index d37c2211462b..b500599009ee 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class JobsOperations: - """JobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_nodes_operations.py index aa31f8eb7856..665f0ef166af 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._nodes_operations import build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NodesOperations: - """NodesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.NodeList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +141,8 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_operations.py index 54c30b0a7257..b8762962f715 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,126 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.OperationsList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +134,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_operations_status_operations.py index 63dd79b27a4f..de3a6247add8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations_status_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsStatusOperations: - """OperationsStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_orders_operations.py index 96b8846d7b09..d400dc602089 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._orders_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OrdersOperations: - """OrdersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.OrderList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,110 +151,119 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Order": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } async def _create_or_update_initial( - self, - device_name: str, - resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> Optional["_models.Order"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -226,120 +272,200 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> AsyncLROPoller["_models.Order"]: + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2019_07_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2019_07_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -349,70 +475,71 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_roles_operations.py index a14931080c68..e545340647eb 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._roles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RolesOperations: - """RolesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.RoleList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Role": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> Optional["_models.Role"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +272,203 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> AsyncLROPoller["_models.Role"]: + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2019_07_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2019_07_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +478,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_shares_operations.py index 6954c5453482..2ab4b8c9aaf6 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._shares_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SharesOperations: - """SharesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ShareList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +152,123 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Share": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> Optional["_models.Share"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +277,209 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> AsyncLROPoller["_models.Share"]: + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2019_07_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2019_07_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,112 +489,112 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -477,75 +604,76 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_storage_account_credentials_operations.py index 3b07e3ef0727..bc17c5848e9d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_account_credentials_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountCredentialsOperations: - """StorageAccountCredentialsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountCredentialList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,114 +152,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccountCredential": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> Optional["_models.StorageAccountCredential"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -230,125 +282,217 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccountCredential"]: + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,73 +502,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_triggers_operations.py index f6e6ef43282e..37ad294f2c4f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._triggers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TriggersOperations: - """TriggersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.TriggerList"]: + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +153,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Trigger": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> Optional["_models.Trigger"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,125 +276,206 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> AsyncLROPoller["_models.Trigger"]: + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2019_07_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Trigger or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Trigger or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2019_07_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +485,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_users_operations.py index e1ee77cc8705..f6e71f22d203 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/aio/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UsersOperations: - """UsersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.aio.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.UserList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 UserList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.User": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - user: "_models.User", - **kwargs - ) -> Optional["_models.User"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,126 +272,206 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - user: "_models.User", - **kwargs - ) -> AsyncLROPoller["_models.User"]: + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2019_07_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2019_07_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -357,73 +481,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/__init__.py index 737f7eda04f1..887989c80581 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/__init__.py @@ -6,283 +6,218 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARMBaseModel - from ._models_py3 import Address - from ._models_py3 import Alert - from ._models_py3 import AlertErrorDetails - from ._models_py3 import AlertList - from ._models_py3 import AsymmetricEncryptedSecret - from ._models_py3 import Authentication - from ._models_py3 import AzureContainerInfo - from ._models_py3 import BandwidthSchedule - from ._models_py3 import BandwidthSchedulesList - from ._models_py3 import ClientAccessRight - from ._models_py3 import CloudErrorBody - from ._models_py3 import ContactDetails - from ._models_py3 import DataBoxEdgeDevice - from ._models_py3 import DataBoxEdgeDeviceExtendedInfo - from ._models_py3 import DataBoxEdgeDeviceList - from ._models_py3 import DataBoxEdgeDevicePatch - from ._models_py3 import FileEventTrigger - from ._models_py3 import FileSourceInfo - from ._models_py3 import IoTDeviceInfo - from ._models_py3 import IoTRole - from ._models_py3 import Ipv4Config - from ._models_py3 import Ipv6Config - from ._models_py3 import Job - from ._models_py3 import JobErrorDetails - from ._models_py3 import JobErrorItem - from ._models_py3 import MetricDimensionV1 - from ._models_py3 import MetricSpecificationV1 - from ._models_py3 import MountPointMap - from ._models_py3 import NetworkAdapter - from ._models_py3 import NetworkAdapterPosition - from ._models_py3 import NetworkSettings - from ._models_py3 import Node - from ._models_py3 import NodeList - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import Order - from ._models_py3 import OrderList - from ._models_py3 import OrderStatus - from ._models_py3 import PeriodicTimerEventTrigger - from ._models_py3 import PeriodicTimerSourceInfo - from ._models_py3 import RefreshDetails - from ._models_py3 import Role - from ._models_py3 import RoleList - from ._models_py3 import RoleSinkInfo - from ._models_py3 import SecuritySettings - from ._models_py3 import ServiceSpecification - from ._models_py3 import Share - from ._models_py3 import ShareAccessRight - from ._models_py3 import ShareList - from ._models_py3 import Sku - from ._models_py3 import StorageAccountCredential - from ._models_py3 import StorageAccountCredentialList - from ._models_py3 import SymmetricKey - from ._models_py3 import TrackingInfo - from ._models_py3 import Trigger - from ._models_py3 import TriggerList - from ._models_py3 import UpdateDownloadProgress - from ._models_py3 import UpdateInstallProgress - from ._models_py3 import UpdateSummary - from ._models_py3 import UploadCertificateRequest - from ._models_py3 import UploadCertificateResponse - from ._models_py3 import User - from ._models_py3 import UserAccessRight - from ._models_py3 import UserList -except (SyntaxError, ImportError): - from ._models import ARMBaseModel # type: ignore - from ._models import Address # type: ignore - from ._models import Alert # type: ignore - from ._models import AlertErrorDetails # type: ignore - from ._models import AlertList # type: ignore - from ._models import AsymmetricEncryptedSecret # type: ignore - from ._models import Authentication # type: ignore - from ._models import AzureContainerInfo # type: ignore - from ._models import BandwidthSchedule # type: ignore - from ._models import BandwidthSchedulesList # type: ignore - from ._models import ClientAccessRight # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import ContactDetails # type: ignore - from ._models import DataBoxEdgeDevice # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfo # type: ignore - from ._models import DataBoxEdgeDeviceList # type: ignore - from ._models import DataBoxEdgeDevicePatch # type: ignore - from ._models import FileEventTrigger # type: ignore - from ._models import FileSourceInfo # type: ignore - from ._models import IoTDeviceInfo # type: ignore - from ._models import IoTRole # type: ignore - from ._models import Ipv4Config # type: ignore - from ._models import Ipv6Config # type: ignore - from ._models import Job # type: ignore - from ._models import JobErrorDetails # type: ignore - from ._models import JobErrorItem # type: ignore - from ._models import MetricDimensionV1 # type: ignore - from ._models import MetricSpecificationV1 # type: ignore - from ._models import MountPointMap # type: ignore - from ._models import NetworkAdapter # type: ignore - from ._models import NetworkAdapterPosition # type: ignore - from ._models import NetworkSettings # type: ignore - from ._models import Node # type: ignore - from ._models import NodeList # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import Order # type: ignore - from ._models import OrderList # type: ignore - from ._models import OrderStatus # type: ignore - from ._models import PeriodicTimerEventTrigger # type: ignore - from ._models import PeriodicTimerSourceInfo # type: ignore - from ._models import RefreshDetails # type: ignore - from ._models import Role # type: ignore - from ._models import RoleList # type: ignore - from ._models import RoleSinkInfo # type: ignore - from ._models import SecuritySettings # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Share # type: ignore - from ._models import ShareAccessRight # type: ignore - from ._models import ShareList # type: ignore - from ._models import Sku # type: ignore - from ._models import StorageAccountCredential # type: ignore - from ._models import StorageAccountCredentialList # type: ignore - from ._models import SymmetricKey # type: ignore - from ._models import TrackingInfo # type: ignore - from ._models import Trigger # type: ignore - from ._models import TriggerList # type: ignore - from ._models import UpdateDownloadProgress # type: ignore - from ._models import UpdateInstallProgress # type: ignore - from ._models import UpdateSummary # type: ignore - from ._models import UploadCertificateRequest # type: ignore - from ._models import UploadCertificateResponse # type: ignore - from ._models import User # type: ignore - from ._models import UserAccessRight # type: ignore - from ._models import UserList # type: ignore +from ._models_py3 import ARMBaseModel +from ._models_py3 import Address +from ._models_py3 import Alert +from ._models_py3 import AlertErrorDetails +from ._models_py3 import AlertList +from ._models_py3 import AsymmetricEncryptedSecret +from ._models_py3 import Authentication +from ._models_py3 import AzureContainerInfo +from ._models_py3 import BandwidthSchedule +from ._models_py3 import BandwidthSchedulesList +from ._models_py3 import ClientAccessRight +from ._models_py3 import CloudErrorBody +from ._models_py3 import ContactDetails +from ._models_py3 import DataBoxEdgeDevice +from ._models_py3 import DataBoxEdgeDeviceExtendedInfo +from ._models_py3 import DataBoxEdgeDeviceList +from ._models_py3 import DataBoxEdgeDevicePatch +from ._models_py3 import FileEventTrigger +from ._models_py3 import FileSourceInfo +from ._models_py3 import IoTDeviceInfo +from ._models_py3 import IoTRole +from ._models_py3 import Ipv4Config +from ._models_py3 import Ipv6Config +from ._models_py3 import Job +from ._models_py3 import JobErrorDetails +from ._models_py3 import JobErrorItem +from ._models_py3 import MetricDimensionV1 +from ._models_py3 import MetricSpecificationV1 +from ._models_py3 import MountPointMap +from ._models_py3 import NetworkAdapter +from ._models_py3 import NetworkAdapterPosition +from ._models_py3 import NetworkSettings +from ._models_py3 import Node +from ._models_py3 import NodeList +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import Order +from ._models_py3 import OrderList +from ._models_py3 import OrderStatus +from ._models_py3 import PeriodicTimerEventTrigger +from ._models_py3 import PeriodicTimerSourceInfo +from ._models_py3 import RefreshDetails +from ._models_py3 import Role +from ._models_py3 import RoleList +from ._models_py3 import RoleSinkInfo +from ._models_py3 import SecuritySettings +from ._models_py3 import ServiceSpecification +from ._models_py3 import Share +from ._models_py3 import ShareAccessRight +from ._models_py3 import ShareList +from ._models_py3 import Sku +from ._models_py3 import StorageAccountCredential +from ._models_py3 import StorageAccountCredentialList +from ._models_py3 import SymmetricKey +from ._models_py3 import TrackingInfo +from ._models_py3 import Trigger +from ._models_py3 import TriggerList +from ._models_py3 import UpdateDownloadProgress +from ._models_py3 import UpdateInstallProgress +from ._models_py3 import UpdateSummary +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UploadCertificateResponse +from ._models_py3 import User +from ._models_py3 import UserAccessRight +from ._models_py3 import UserList -from ._data_box_edge_management_client_enums import ( - AccountType, - AlertSeverity, - AuthenticationType, - AzureContainerDataFormat, - ClientPermissionType, - DataBoxEdgeDeviceStatus, - DataPolicy, - DayOfWeek, - DeviceType, - DownloadPhase, - EncryptionAlgorithm, - InstallRebootBehavior, - JobStatus, - JobType, - MetricAggregationType, - MetricCategory, - MetricUnit, - MonitoringStatus, - NetworkAdapterDHCPStatus, - NetworkAdapterRDMAStatus, - NetworkAdapterStatus, - NetworkGroup, - NodeStatus, - OrderState, - PlatformType, - RoleStatus, - RoleTypes, - SSLStatus, - ShareAccessProtocol, - ShareAccessType, - ShareStatus, - SkuName, - SkuTier, - TimeGrain, - TriggerEventType, - UpdateOperation, - UpdateOperationStage, -) +from ._data_box_edge_management_client_enums import AccountType +from ._data_box_edge_management_client_enums import AlertSeverity +from ._data_box_edge_management_client_enums import AuthenticationType +from ._data_box_edge_management_client_enums import AzureContainerDataFormat +from ._data_box_edge_management_client_enums import ClientPermissionType +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceStatus +from ._data_box_edge_management_client_enums import DataPolicy +from ._data_box_edge_management_client_enums import DayOfWeek +from ._data_box_edge_management_client_enums import DeviceType +from ._data_box_edge_management_client_enums import DownloadPhase +from ._data_box_edge_management_client_enums import EncryptionAlgorithm +from ._data_box_edge_management_client_enums import InstallRebootBehavior +from ._data_box_edge_management_client_enums import JobStatus +from ._data_box_edge_management_client_enums import JobType +from ._data_box_edge_management_client_enums import MetricAggregationType +from ._data_box_edge_management_client_enums import MetricCategory +from ._data_box_edge_management_client_enums import MetricUnit +from ._data_box_edge_management_client_enums import MonitoringStatus +from ._data_box_edge_management_client_enums import NetworkAdapterDHCPStatus +from ._data_box_edge_management_client_enums import NetworkAdapterRDMAStatus +from ._data_box_edge_management_client_enums import NetworkAdapterStatus +from ._data_box_edge_management_client_enums import NetworkGroup +from ._data_box_edge_management_client_enums import NodeStatus +from ._data_box_edge_management_client_enums import OrderState +from ._data_box_edge_management_client_enums import PlatformType +from ._data_box_edge_management_client_enums import RoleStatus +from ._data_box_edge_management_client_enums import RoleTypes +from ._data_box_edge_management_client_enums import SSLStatus +from ._data_box_edge_management_client_enums import ShareAccessProtocol +from ._data_box_edge_management_client_enums import ShareAccessType +from ._data_box_edge_management_client_enums import ShareStatus +from ._data_box_edge_management_client_enums import SkuName +from ._data_box_edge_management_client_enums import SkuTier +from ._data_box_edge_management_client_enums import TimeGrain +from ._data_box_edge_management_client_enums import TriggerEventType +from ._data_box_edge_management_client_enums import UpdateOperation +from ._data_box_edge_management_client_enums import UpdateOperationStage +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ARMBaseModel', - 'Address', - 'Alert', - 'AlertErrorDetails', - 'AlertList', - 'AsymmetricEncryptedSecret', - 'Authentication', - 'AzureContainerInfo', - 'BandwidthSchedule', - 'BandwidthSchedulesList', - 'ClientAccessRight', - 'CloudErrorBody', - 'ContactDetails', - 'DataBoxEdgeDevice', - 'DataBoxEdgeDeviceExtendedInfo', - 'DataBoxEdgeDeviceList', - 'DataBoxEdgeDevicePatch', - 'FileEventTrigger', - 'FileSourceInfo', - 'IoTDeviceInfo', - 'IoTRole', - 'Ipv4Config', - 'Ipv6Config', - 'Job', - 'JobErrorDetails', - 'JobErrorItem', - 'MetricDimensionV1', - 'MetricSpecificationV1', - 'MountPointMap', - 'NetworkAdapter', - 'NetworkAdapterPosition', - 'NetworkSettings', - 'Node', - 'NodeList', - 'Operation', - 'OperationDisplay', - 'OperationsList', - 'Order', - 'OrderList', - 'OrderStatus', - 'PeriodicTimerEventTrigger', - 'PeriodicTimerSourceInfo', - 'RefreshDetails', - 'Role', - 'RoleList', - 'RoleSinkInfo', - 'SecuritySettings', - 'ServiceSpecification', - 'Share', - 'ShareAccessRight', - 'ShareList', - 'Sku', - 'StorageAccountCredential', - 'StorageAccountCredentialList', - 'SymmetricKey', - 'TrackingInfo', - 'Trigger', - 'TriggerList', - 'UpdateDownloadProgress', - 'UpdateInstallProgress', - 'UpdateSummary', - 'UploadCertificateRequest', - 'UploadCertificateResponse', - 'User', - 'UserAccessRight', - 'UserList', - 'AccountType', - 'AlertSeverity', - 'AuthenticationType', - 'AzureContainerDataFormat', - 'ClientPermissionType', - 'DataBoxEdgeDeviceStatus', - 'DataPolicy', - 'DayOfWeek', - 'DeviceType', - 'DownloadPhase', - 'EncryptionAlgorithm', - 'InstallRebootBehavior', - 'JobStatus', - 'JobType', - 'MetricAggregationType', - 'MetricCategory', - 'MetricUnit', - 'MonitoringStatus', - 'NetworkAdapterDHCPStatus', - 'NetworkAdapterRDMAStatus', - 'NetworkAdapterStatus', - 'NetworkGroup', - 'NodeStatus', - 'OrderState', - 'PlatformType', - 'RoleStatus', - 'RoleTypes', - 'SSLStatus', - 'ShareAccessProtocol', - 'ShareAccessType', - 'ShareStatus', - 'SkuName', - 'SkuTier', - 'TimeGrain', - 'TriggerEventType', - 'UpdateOperation', - 'UpdateOperationStage', + "ARMBaseModel", + "Address", + "Alert", + "AlertErrorDetails", + "AlertList", + "AsymmetricEncryptedSecret", + "Authentication", + "AzureContainerInfo", + "BandwidthSchedule", + "BandwidthSchedulesList", + "ClientAccessRight", + "CloudErrorBody", + "ContactDetails", + "DataBoxEdgeDevice", + "DataBoxEdgeDeviceExtendedInfo", + "DataBoxEdgeDeviceList", + "DataBoxEdgeDevicePatch", + "FileEventTrigger", + "FileSourceInfo", + "IoTDeviceInfo", + "IoTRole", + "Ipv4Config", + "Ipv6Config", + "Job", + "JobErrorDetails", + "JobErrorItem", + "MetricDimensionV1", + "MetricSpecificationV1", + "MountPointMap", + "NetworkAdapter", + "NetworkAdapterPosition", + "NetworkSettings", + "Node", + "NodeList", + "Operation", + "OperationDisplay", + "OperationsList", + "Order", + "OrderList", + "OrderStatus", + "PeriodicTimerEventTrigger", + "PeriodicTimerSourceInfo", + "RefreshDetails", + "Role", + "RoleList", + "RoleSinkInfo", + "SecuritySettings", + "ServiceSpecification", + "Share", + "ShareAccessRight", + "ShareList", + "Sku", + "StorageAccountCredential", + "StorageAccountCredentialList", + "SymmetricKey", + "TrackingInfo", + "Trigger", + "TriggerList", + "UpdateDownloadProgress", + "UpdateInstallProgress", + "UpdateSummary", + "UploadCertificateRequest", + "UploadCertificateResponse", + "User", + "UserAccessRight", + "UserList", + "AccountType", + "AlertSeverity", + "AuthenticationType", + "AzureContainerDataFormat", + "ClientPermissionType", + "DataBoxEdgeDeviceStatus", + "DataPolicy", + "DayOfWeek", + "DeviceType", + "DownloadPhase", + "EncryptionAlgorithm", + "InstallRebootBehavior", + "JobStatus", + "JobType", + "MetricAggregationType", + "MetricCategory", + "MetricUnit", + "MonitoringStatus", + "NetworkAdapterDHCPStatus", + "NetworkAdapterRDMAStatus", + "NetworkAdapterStatus", + "NetworkGroup", + "NodeStatus", + "OrderState", + "PlatformType", + "RoleStatus", + "RoleTypes", + "SSLStatus", + "ShareAccessProtocol", + "ShareAccessType", + "ShareStatus", + "SkuName", + "SkuTier", + "TimeGrain", + "TriggerEventType", + "UpdateOperation", + "UpdateOperationStage", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_data_box_edge_management_client_enums.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_data_box_edge_management_client_enums.py index 6093033a5f34..0aaeddf75789 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_data_box_edge_management_client_enums.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_data_box_edge_management_client_enums.py @@ -6,67 +6,50 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of storage accessed on the storage account. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of storage accessed on the storage account.""" GENERAL_PURPOSE_STORAGE = "GeneralPurposeStorage" BLOB_STORAGE = "BlobStorage" -class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the alert. - """ + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert.""" INFORMATIONAL = "Informational" WARNING = "Warning" CRITICAL = "Critical" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The authentication type. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication type.""" INVALID = "Invalid" AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" -class AzureContainerDataFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Storage format used for the file represented by the share. - """ + +class AzureContainerDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage format used for the file represented by the share.""" BLOCK_BLOB = "BlockBlob" PAGE_BLOB = "PageBlob" AZURE_FILE = "AzureFile" -class ClientPermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed for the client. - """ + +class ClientPermissionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed for the client.""" NO_ACCESS = "NoAccess" READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the Data Box Edge/Gateway device. - """ + +class DataBoxEdgeDeviceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the Data Box Edge/Gateway device.""" READY_TO_SETUP = "ReadyToSetup" ONLINE = "Online" @@ -76,14 +59,16 @@ class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum PARTIALLY_DISCONNECTED = "PartiallyDisconnected" MAINTENANCE = "Maintenance" -class DataPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Data policy of the share. - """ + +class DataPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data policy of the share.""" CLOUD = "Cloud" LOCAL = "Local" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -93,40 +78,40 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DeviceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the Data Box Edge/Gateway device. - """ + +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the Data Box Edge/Gateway device.""" DATA_BOX_EDGE_DEVICE = "DataBoxEdgeDevice" -class DownloadPhase(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The download phase. - """ + +class DownloadPhase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The download phase.""" UNKNOWN = "Unknown" INITIALIZING = "Initializing" DOWNLOADING = "Downloading" VERIFYING = "Verifying" -class EncryptionAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The algorithm used to encrypt "Value". - """ + +class EncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The algorithm used to encrypt "Value".""" NONE = "None" AES256 = "AES256" RSAES_PKCS1_V1_5 = "RSAES_PKCS1_v_1_5" -class InstallRebootBehavior(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if updates are available and at least one of the updates needs a reboot. - """ + +class InstallRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if updates are available and at least one of the updates needs a reboot.""" NEVER_REBOOTS = "NeverReboots" REQUIRES_REBOOT = "RequiresReboot" REQUEST_REBOOT = "RequestReboot" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the job.""" INVALID = "Invalid" RUNNING = "Running" @@ -136,9 +121,9 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PAUSED = "Paused" SCHEDULED = "Scheduled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" INVALID = "Invalid" SCAN_FOR_UPDATES = "ScanForUpdates" @@ -146,9 +131,9 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INSTALL_UPDATES = "InstallUpdates" REFRESH_SHARE = "RefreshShare" -class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric aggregation type. - """ + +class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric aggregation type.""" NOT_SPECIFIED = "NotSpecified" NONE = "None" @@ -158,16 +143,16 @@ class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) TOTAL = "Total" COUNT = "Count" -class MetricCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric category. - """ + +class MetricCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric category.""" CAPACITY = "Capacity" TRANSACTION = "Transaction" -class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric units. - """ + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric units.""" NOT_SPECIFIED = "NotSpecified" PERCENT = "Percent" @@ -178,45 +163,45 @@ class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BYTES_PER_SECOND = "BytesPerSecond" COUNT_PER_SECOND = "CountPerSecond" -class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current monitoring status of the share. - """ + +class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current monitoring status of the share.""" ENABLED = "Enabled" DISABLED = "Disabled" -class NetworkAdapterDHCPStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter has DHCP enabled. - """ + +class NetworkAdapterDHCPStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter has DHCP enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" -class NetworkAdapterRDMAStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is RDMA capable. - """ + +class NetworkAdapterRDMAStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is RDMA capable.""" INCAPABLE = "Incapable" CAPABLE = "Capable" -class NetworkAdapterStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is valid. - """ + +class NetworkAdapterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is valid.""" INACTIVE = "Inactive" ACTIVE = "Active" -class NetworkGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The network group. - """ + +class NetworkGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network group.""" NONE = "None" NON_RDMA = "NonRDMA" RDMA = "RDMA" -class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the individual node - """ + +class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the individual node.""" UNKNOWN = "Unknown" UP = "Up" @@ -224,9 +209,9 @@ class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REBOOTING = "Rebooting" SHUTTING_DOWN = "ShuttingDown" -class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the order as per the allowed status types. - """ + +class OrderState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the order as per the allowed status types.""" UNTRACKED = "Untracked" AWAITING_FULFILMENT = "AwaitingFulfilment" @@ -243,45 +228,47 @@ class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SHIPPED_BACK = "ShippedBack" COLLECTED_AT_MICROSOFT = "CollectedAtMicrosoft" -class PlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Host OS supported by the IoT role. - """ + +class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host OS supported by the IoT role.""" WINDOWS = "Windows" LINUX = "Linux" -class RoleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Role status. - """ + +class RoleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Role status.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RoleTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleTypes.""" IOT = "IOT" ASA = "ASA" FUNCTIONS = "Functions" COGNITIVE = "Cognitive" -class ShareAccessProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Access protocol to be used by the share. - """ + +class ShareAccessProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access protocol to be used by the share.""" SMB = "SMB" NFS = "NFS" -class ShareAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed on the share for this user. - """ + +class ShareAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed on the share for this user.""" CHANGE = "Change" READ = "Read" CUSTOM = "Custom" -class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the share. - """ + +class ShareStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the share.""" OFFLINE = "Offline" UNKNOWN = "Unknown" @@ -289,27 +276,29 @@ class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """SKU name. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SKU name.""" GATEWAY = "Gateway" EDGE = "Edge" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The SKU tier. This is based on the SKU name. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" -class SSLStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Signifies whether SSL needs to be enabled or not. - """ + +class SSLStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Signifies whether SSL needs to be enabled or not.""" ENABLED = "Enabled" DISABLED = "Disabled" -class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class TimeGrain(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TimeGrain.""" PT1_M = "PT1M" PT5_M = "PT5M" @@ -320,25 +309,25 @@ class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PT12_H = "PT12H" PT1_D = "PT1D" -class TriggerEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Trigger Kind. - """ + +class TriggerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trigger Kind.""" FILE_EVENT = "FileEvent" PERIODIC_TIMER_EVENT = "PeriodicTimerEvent" -class UpdateOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current update operation. - """ + +class UpdateOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current update operation.""" NONE = "None" SCAN = "Scan" DOWNLOAD = "Download" INSTALL = "Install" -class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current stage of the update operation. - """ + +class UpdateOperationStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current stage of the update operation.""" UNKNOWN = "Unknown" INITIAL = "Initial" diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_models.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_models.py deleted file mode 100644 index 9a3963db001b..000000000000 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_models.py +++ /dev/null @@ -1,2861 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class Address(msrest.serialization.Model): - """The shipping address of the customer. - - All required parameters must be populated in order to send to Azure. - - :param address_line1: Required. The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: Required. The postal code. - :type postal_code: str - :param city: Required. The city name. - :type city: str - :param state: Required. The state name. - :type state: str - :param country: Required. The country name. - :type country: str - """ - - _validation = { - 'address_line1': {'required': True}, - 'postal_code': {'required': True}, - 'city': {'required': True}, - 'state': {'required': True}, - 'country': {'required': True}, - } - - _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Address, self).__init__(**kwargs) - self.address_line1 = kwargs['address_line1'] - self.address_line2 = kwargs.get('address_line2', None) - self.address_line3 = kwargs.get('address_line3', None) - self.postal_code = kwargs['postal_code'] - self.city = kwargs['city'] - self.state = kwargs['state'] - self.country = kwargs['country'] - - -class ARMBaseModel(msrest.serialization.Model): - """Represents the base class for all object models. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Alert(ARMBaseModel): - """Alert on the data box edge/gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar title: Alert title. - :vartype title: str - :ivar alert_type: Alert type. - :vartype alert_type: str - :ivar appeared_at_date_time: UTC time when the alert appeared. - :vartype appeared_at_date_time: ~datetime.datetime - :ivar recommendation: Alert recommendation. - :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", - "Critical". - :vartype severity: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AlertSeverity - :ivar error_details: Error details of the alert. - :vartype error_details: ~azure.mgmt.databoxedge.v2019_07_01.models.AlertErrorDetails - :ivar detailed_information: Alert details. - :vartype detailed_information: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) - self.title = None - self.alert_type = None - self.appeared_at_date_time = None - self.recommendation = None - self.severity = None - self.error_details = None - self.detailed_information = None - - -class AlertErrorDetails(msrest.serialization.Model): - """Error details for the alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code. - :vartype error_code: str - :ivar error_message: Error Message. - :vartype error_message: str - :ivar occurrences: Number of occurrences. - :vartype occurrences: int - """ - - _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) - self.error_code = None - self.error_message = None - self.occurrences = None - - -class AlertList(msrest.serialization.Model): - """Collection of alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Alert] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class AsymmetricEncryptedSecret(msrest.serialization.Model): - """Represent the secrets intended for encryption with asymmetric key pair. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the - value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or - ~azure.mgmt.databoxedge.v2019_07_01.models.EncryptionAlgorithm - """ - - _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) - self.value = kwargs['value'] - self.encryption_cert_thumbprint = kwargs.get('encryption_cert_thumbprint', None) - self.encryption_algorithm = kwargs['encryption_algorithm'] - - -class Authentication(msrest.serialization.Model): - """Authentication mechanism for IoT devices. - - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2019_07_01.models.SymmetricKey - """ - - _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, - } - - def __init__( - self, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) - self.symmetric_key = kwargs.get('symmetric_key', None) - - -class AzureContainerInfo(msrest.serialization.Model): - """Azure container mapping of the endpoint. - - All required parameters must be populated in order to send to Azure. - - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AzureContainerDataFormat - """ - - _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, - } - - _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) - self.storage_account_credential_id = kwargs['storage_account_credential_id'] - self.container_name = kwargs['container_name'] - self.data_format = kwargs['data_format'] - - -class BandwidthSchedule(ARMBaseModel): - """The bandwidth schedule details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2019_07_01.models.DayOfWeek] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) - self.start = kwargs['start'] - self.stop = kwargs['stop'] - self.rate_in_mbps = kwargs['rate_in_mbps'] - self.days = kwargs['days'] - - -class BandwidthSchedulesList(msrest.serialization.Model): - """The collection of bandwidth schedules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of bandwidth schedules. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ClientAccessRight(msrest.serialization.Model): - """The mapping between a particular client IP and the type of access client has on the NFS share. - - All required parameters must be populated in order to send to Azure. - - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ClientPermissionType - """ - - _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, - } - - _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) - self.client = kwargs['client'] - self.access_permission = kwargs['access_permission'] - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2019_07_01.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class ContactDetails(msrest.serialization.Model): - """Contains all the contact details of the customer. - - All required parameters must be populated in order to send to Azure. - - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] - """ - - _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) - self.contact_person = kwargs['contact_person'] - self.company_name = kwargs['company_name'] - self.phone = kwargs['phone'] - self.email_list = kwargs['email_list'] - - -class DataBoxEdgeDevice(ARMBaseModel): - """The Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure - geographical region (for example, West US, East US, or Southeast Asia). The geographical region - of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2019_07_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or - ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDeviceStatus - :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. - :vartype serial_number: str - :param description: The Description of the Data Box Edge/Gateway device. - :type description: str - :param model_description: The description of the Data Box Edge/Gateway device model. - :type model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". - :vartype device_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.DeviceType - :param friendly_name: The Data Box Edge/Gateway device name. - :type friendly_name: str - :ivar culture: The Data Box Edge/Gateway device culture. - :vartype culture: str - :ivar device_model: The Data Box Edge/Gateway device model. - :vartype device_model: str - :ivar device_software_version: The Data Box Edge/Gateway device software version. - :vartype device_software_version: str - :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long - :ivar time_zone: The Data Box Edge/Gateway device timezone. - :vartype time_zone: str - :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). - :vartype device_hcs_version: str - :ivar configured_role_types: Type of compute roles configured. - :vartype configured_role_types: list[str or - ~azure.mgmt.databoxedge.v2019_07_01.models.RoleTypes] - :ivar node_count: The number of nodes in the cluster. - :vartype node_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'serial_number': {'readonly': True}, - 'device_type': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - self.etag = kwargs.get('etag', None) - self.data_box_edge_device_status = kwargs.get('data_box_edge_device_status', None) - self.serial_number = None - self.description = kwargs.get('description', None) - self.model_description = kwargs.get('model_description', None) - self.device_type = None - self.friendly_name = kwargs.get('friendly_name', None) - self.culture = None - self.device_model = None - self.device_software_version = None - self.device_local_capacity = None - self.time_zone = None - self.device_hcs_version = None - self.configured_role_types = None - self.node_count = None - - -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): - """The extended Info of the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to - encrypt any secret. - :type encryption_key: str - :ivar resource_key: The Resource ID of the Resource. - :vartype resource_key: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) - self.encryption_key_thumbprint = kwargs.get('encryption_key_thumbprint', None) - self.encryption_key = kwargs.get('encryption_key', None) - self.resource_key = None - - -class DataBoxEdgeDeviceList(msrest.serialization.Model): - """The collection of Data Box Edge/Gateway devices. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Data Box Edge/Gateway devices. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevicePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device patch. - - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class Trigger(ARMBaseModel): - """Trigger details. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.TriggerEventType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } - - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.kind = 'Trigger' # type: str - - -class FileEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2019_07_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2019_07_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class FileSourceInfo(msrest.serialization.Model): - """File source details. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. File share ID. - :type share_id: str - """ - - _validation = { - 'share_id': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - - -class IoTDeviceInfo(msrest.serialization.Model): - """Metadata of IoT device/IoT Edge device to be configured. - - All required parameters must be populated in order to send to Azure. - - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id of the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: IoT device authentication info. - :type authentication: ~azure.mgmt.databoxedge.v2019_07_01.models.Authentication - """ - - _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) - self.device_id = kwargs['device_id'] - self.io_t_host_hub = kwargs['io_t_host_hub'] - self.io_t_host_hub_id = kwargs.get('io_t_host_hub_id', None) - self.authentication = kwargs.get('authentication', None) - - -class Role(ARMBaseModel): - """Compute role. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: IoTRole. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleTypes - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'IOT': 'IoTRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str - - -class IoTRole(Role): - """Compute role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleTypes - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", - "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2019_07_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2019_07_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_07_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2019_07_01.models.MountPointMap] - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.io_t_device_details = kwargs.get('io_t_device_details', None) - self.io_t_edge_device_details = kwargs.get('io_t_edge_device_details', None) - self.share_mappings = kwargs.get('share_mappings', None) - self.role_status = kwargs.get('role_status', None) - - -class Ipv4Config(msrest.serialization.Model): - """Details related to the IPv4 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv4 address of the network adapter. - :vartype ip_address: str - :ivar subnet: The IPv4 subnet of the network adapter. - :vartype subnet: str - :ivar gateway: The IPv4 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) - self.ip_address = None - self.subnet = None - self.gateway = None - - -class Ipv6Config(msrest.serialization.Model): - """Details related to the IPv6 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv6 address of the network adapter. - :vartype ip_address: str - :ivar prefix_length: The IPv6 prefix of the network adapter. - :vartype prefix_length: int - :ivar gateway: The IPv6 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) - self.ip_address = None - self.prefix_length = None - self.gateway = None - - -class Job(msrest.serialization.Model): - """A device job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The name of the object. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.JobStatus - :ivar start_time: The UTC date and time at which the job started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The UTC date and time at which the job completed. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: The percentage of the job that is complete. - :vartype percent_complete: int - :ivar error: The error details. - :vartype error: ~azure.mgmt.databoxedge.v2019_07_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare". - :vartype job_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", - "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", - "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". - :vartype current_stage: str or ~azure.mgmt.databoxedge.v2019_07_01.models.UpdateOperationStage - :ivar download_progress: The download progress. - :vartype download_progress: ~azure.mgmt.databoxedge.v2019_07_01.models.UpdateDownloadProgress - :ivar install_progress: The install progress. - :vartype install_progress: ~azure.mgmt.databoxedge.v2019_07_01.models.UpdateInstallProgress - :ivar total_refresh_errors: Total number of errors encountered during the refresh process. - :vartype total_refresh_errors: int - :ivar error_manifest_file: Local share/remote container relative path to the error manifest - file of the refresh. - :vartype error_manifest_file: str - :ivar share_id: ARM ID of the share that was refreshed. - :vartype share_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'share_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'share_id': {'key': 'properties.shareId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_time = None - self.end_time = None - self.percent_complete = None - self.error = None - self.job_type = None - self.current_stage = None - self.download_progress = None - self.install_progress = None - self.total_refresh_errors = None - self.error_manifest_file = None - self.share_id = None - self.folder = kwargs.get('folder', None) - - -class JobErrorDetails(msrest.serialization.Model): - """The job error information containing the list of job errors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_details: The error details. - :vartype error_details: list[~azure.mgmt.databoxedge.v2019_07_01.models.JobErrorItem] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) - self.error_details = None - self.code = None - self.message = None - - -class JobErrorItem(msrest.serialization.Model): - """The job error items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendations: The recommended actions. - :vartype recommendations: list[str] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) - self.recommendations = None - self.code = None - self.message = None - - -class MetricDimensionV1(msrest.serialization.Model): - """Metric Dimension v1. - - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimensionV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecificationV1(msrest.serialization.Model): - """Metric specification version 1. - - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2019_07_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or - ~azure.mgmt.databoxedge.v2019_07_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or - ~azure.mgmt.databoxedge.v2019_07_01.models.MetricAggregationType] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.dimensions = kwargs.get('dimensions', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - - -class MountPointMap(msrest.serialization.Model): - """The share mount point. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str - :ivar role_id: ID of the role to which share is mounted. - :vartype role_id: str - :ivar mount_point: Mount point for the share. - :vartype mount_point: str - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive". - :vartype role_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleTypes - """ - - _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'role_type': {'readonly': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.role_id = None - self.mount_point = None - self.role_type = None - - -class NetworkAdapter(msrest.serialization.Model): - """Represents the networkAdapter on a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar adapter_id: Instance ID of network adapter. - :vartype adapter_id: str - :ivar adapter_position: Hardware position of network adapter. - :vartype adapter_position: ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterPosition - :ivar index: Logical index of the adapter. - :vartype index: int - :ivar node_id: Node ID of the network adapter. - :vartype node_id: str - :ivar network_adapter_name: Network adapter name. - :vartype network_adapter_name: str - :ivar label: Hardware label for the adapter. - :vartype label: str - :ivar mac_address: MAC address. - :vartype mac_address: str - :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". - :vartype status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterDHCPStatus - :ivar ipv4_configuration: The IPv4 configuration of the network adapter. - :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2019_07_01.models.Ipv4Config - :ivar ipv6_configuration: The IPv6 configuration of the network adapter. - :vartype ipv6_configuration: ~azure.mgmt.databoxedge.v2019_07_01.models.Ipv6Config - :ivar ipv6_link_local_address: The IPv6 local address. - :vartype ipv6_link_local_address: str - :ivar dns_servers: The list of DNS Servers of the device. - :vartype dns_servers: list[str] - """ - - _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) - self.adapter_id = None - self.adapter_position = None - self.index = None - self.node_id = None - self.network_adapter_name = None - self.label = None - self.mac_address = None - self.link_speed = None - self.status = None - self.rdma_status = kwargs.get('rdma_status', None) - self.dhcp_status = kwargs.get('dhcp_status', None) - self.ipv4_configuration = None - self.ipv6_configuration = None - self.ipv6_link_local_address = None - self.dns_servers = None - - -class NetworkAdapterPosition(msrest.serialization.Model): - """The network adapter position. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". - :vartype network_group: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkGroup - :ivar port: The port. - :vartype port: int - """ - - _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, - } - - _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) - self.network_group = None - self.port = None - - -class NetworkSettings(ARMBaseModel): - """The network settings of a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar network_adapters: The network adapter list on the device. - :vartype network_adapters: list[~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapter] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) - self.network_adapters = None - - -class Node(ARMBaseModel): - """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) - self.node_status = None - self.node_chassis_serial_number = None - self.node_serial_number = None - self.node_display_name = None - self.node_friendly_software_version = None - self.node_hcs_version = None - self.node_instance_id = None - - -class NodeList(msrest.serialization.Model): - """Collection of Nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Nodes. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Node] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) - self.value = None - - -class Operation(msrest.serialization.Model): - """Operations. - - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2019_07_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2019_07_01.models.ServiceSpecification - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationDisplay(msrest.serialization.Model): - """Operation display properties. - - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str - """ - - _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 = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """The list of operations used for the discovery of available provider operations. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class Order(ARMBaseModel): - """The order details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2019_07_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2019_07_01.models.Address - :param current_status: Current status of the order. - :type current_status: ~azure.mgmt.databoxedge.v2019_07_01.models.OrderStatus - :ivar order_history: List of status changes in the order. - :vartype order_history: list[~azure.mgmt.databoxedge.v2019_07_01.models.OrderStatus] - :ivar serial_number: Serial number of the device. - :vartype serial_number: str - :ivar delivery_tracking_info: Tracking information for the package delivered to the customer - whether it has an original or a replacement device. - :vartype delivery_tracking_info: list[~azure.mgmt.databoxedge.v2019_07_01.models.TrackingInfo] - :ivar return_tracking_info: Tracking information for the package returned from the customer - whether it has an original or a replacement device. - :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2019_07_01.models.TrackingInfo] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(Order, self).__init__(**kwargs) - self.contact_information = kwargs.get('contact_information', None) - self.shipping_address = kwargs.get('shipping_address', None) - self.current_status = kwargs.get('current_status', None) - self.order_history = None - self.serial_number = None - self.delivery_tracking_info = None - self.return_tracking_info = None - - -class OrderList(msrest.serialization.Model): - """List of order entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of orders. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Order] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OrderStatus(msrest.serialization.Model): - """Represents a single status change. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft". - :type status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.OrderState - :ivar update_date_time: Time of status update. - :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str - """ - - _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) - self.status = kwargs['status'] - self.update_date_time = None - self.comments = kwargs.get('comments', None) - - -class PeriodicTimerEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2019_07_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2019_07_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class PeriodicTimerSourceInfo(msrest.serialization.Model): - """Periodic timer event source. - - All required parameters must be populated in order to send to Azure. - - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str - """ - - _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) - self.start_time = kwargs['start_time'] - self.schedule = kwargs['schedule'] - self.topic = kwargs.get('topic', None) - - -class RefreshDetails(msrest.serialization.Model): - """Fields for tracking refresh job on the share. - - :param in_progress_refresh_job_id: If a refresh share job is currently in progress on this - share, this field indicates the ARM resource ID of that job. The field is empty if no job is in - progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share, if any.This could be a failed job or a successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh - job on this particular share, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share,if any. This - could be a failed job or a successful job. - :type last_job: str - """ - - _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RefreshDetails, self).__init__(**kwargs) - self.in_progress_refresh_job_id = kwargs.get('in_progress_refresh_job_id', None) - self.last_completed_refresh_job_time_in_utc = kwargs.get('last_completed_refresh_job_time_in_utc', None) - self.error_manifest_file = kwargs.get('error_manifest_file', None) - self.last_job = kwargs.get('last_job', None) - - -class RoleList(msrest.serialization.Model): - """Collection of all the roles on the Data Box Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Role] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RoleSinkInfo(msrest.serialization.Model): - """Compute role against which events will be raised. - - All required parameters must be populated in order to send to Azure. - - :param role_id: Required. Compute role ID. - :type role_id: str - """ - - _validation = { - 'role_id': {'required': True}, - } - - _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) - self.role_id = kwargs['role_id'] - - -class SecuritySettings(ARMBaseModel): - """The security settings of a device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: - ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) - self.device_admin_password = kwargs['device_admin_password'] - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification. - - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: - list[~azure.mgmt.databoxedge.v2019_07_01.models.MetricSpecificationV1] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Share(ARMBaseModel): - """Represents a share on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2019_07_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share - (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2019_07_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the - share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2019_07_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2019_07_01.models.RefreshDetails - :ivar share_mappings: Share mount point to the role. - :vartype share_mappings: list[~azure.mgmt.databoxedge.v2019_07_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2019_07_01.models.DataPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Share, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.share_status = kwargs['share_status'] - self.monitoring_status = kwargs['monitoring_status'] - self.azure_container_info = kwargs.get('azure_container_info', None) - self.access_protocol = kwargs['access_protocol'] - self.user_access_rights = kwargs.get('user_access_rights', None) - self.client_access_rights = kwargs.get('client_access_rights', None) - self.refresh_details = kwargs.get('refresh_details', None) - self.share_mappings = None - self.data_policy = kwargs.get('data_policy', None) - - -class ShareAccessRight(msrest.serialization.Model): - """Specifies the mapping between this particular user and the type of access he has on shares on this device. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessType - """ - - _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.access_type = kwargs['access_type'] - - -class ShareList(msrest.serialization.Model): - """Collection of all the shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of shares. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Share] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Sku(msrest.serialization.Model): - """The SKU type. - - :param name: SKU name. Possible values include: "Gateway", "Edge". - :type name: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SkuTier - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - - -class StorageAccountCredential(ARMBaseModel): - """The storage account credential. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredential, self).__init__(**kwargs) - self.alias = kwargs['alias'] - self.user_name = kwargs.get('user_name', None) - self.account_key = kwargs.get('account_key', None) - self.connection_string = kwargs.get('connection_string', None) - self.ssl_status = kwargs['ssl_status'] - self.blob_domain_name = kwargs.get('blob_domain_name', None) - self.account_type = kwargs['account_type'] - self.storage_account_id = kwargs.get('storage_account_id', None) - - -class StorageAccountCredentialList(msrest.serialization.Model): - """The collection of storage account credentials. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SymmetricKey(msrest.serialization.Model): - """Symmetric key for authentication. - - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret - """ - - _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) - self.connection_string = kwargs.get('connection_string', None) - - -class TrackingInfo(msrest.serialization.Model): - """Tracking courier information. - - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str - """ - - _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackingInfo, self).__init__(**kwargs) - self.serial_number = kwargs.get('serial_number', None) - self.carrier_name = kwargs.get('carrier_name', None) - self.tracking_id = kwargs.get('tracking_id', None) - self.tracking_url = kwargs.get('tracking_url', None) - - -class TriggerList(msrest.serialization.Model): - """Collection of all trigger on the data box edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of triggers. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Trigger] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UpdateDownloadProgress(msrest.serialization.Model): - """Details about the download progress of update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". - :vartype download_phase: str or ~azure.mgmt.databoxedge.v2019_07_01.models.DownloadPhase - :ivar percent_complete: Percentage of completion. - :vartype percent_complete: int - :ivar total_bytes_to_download: Total bytes to download. - :vartype total_bytes_to_download: float - :ivar total_bytes_downloaded: Total bytes downloaded. - :vartype total_bytes_downloaded: float - :ivar number_of_updates_to_download: Number of updates to download. - :vartype number_of_updates_to_download: int - :ivar number_of_updates_downloaded: Number of updates downloaded. - :vartype number_of_updates_downloaded: int - """ - - _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, - } - - _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) - self.download_phase = None - self.percent_complete = None - self.total_bytes_to_download = None - self.total_bytes_downloaded = None - self.number_of_updates_to_download = None - self.number_of_updates_downloaded = None - - -class UpdateInstallProgress(msrest.serialization.Model): - """Progress details during installation of updates. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar percent_complete: Percentage completed. - :vartype percent_complete: int - :ivar number_of_updates_to_install: Number of updates to install. - :vartype number_of_updates_to_install: int - :ivar number_of_updates_installed: Number of updates installed. - :vartype number_of_updates_installed: int - """ - - _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, - } - - _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) - self.percent_complete = None - self.number_of_updates_to_install = None - self.number_of_updates_installed = None - - -class UpdateSummary(ARMBaseModel): - """Details about ongoing updates and availability of updates on the device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed - (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime - :ivar last_completed_download_job_date_time: The time when the last Download job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_download_job_date_time: ~datetime.datetime - :ivar last_completed_install_job_date_time: The time when the last Install job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_install_job_date_time: ~datetime.datetime - :ivar total_number_of_updates_available: The number of updates available for the current device - version as per the last device scan. - :vartype total_number_of_updates_available: int - :ivar total_number_of_updates_pending_download: The total number of items pending download. - :vartype total_number_of_updates_pending_download: int - :ivar total_number_of_updates_pending_install: The total number of items pending install. - :vartype total_number_of_updates_pending_install: int - :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.databoxedge.v2019_07_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". - :vartype ongoing_update_operation: str or - ~azure.mgmt.databoxedge.v2019_07_01.models.UpdateOperation - :ivar in_progress_download_job_id: The job ID of the download job in progress. - :vartype in_progress_download_job_id: str - :ivar in_progress_install_job_id: The job ID of the install job in progress. - :vartype in_progress_install_job_id: str - :ivar in_progress_download_job_started_date_time: The time when the currently running download - (if any) started. - :vartype in_progress_download_job_started_date_time: ~datetime.datetime - :ivar in_progress_install_job_started_date_time: The time when the currently running install - (if any) started. - :vartype in_progress_install_job_started_date_time: ~datetime.datetime - :ivar update_titles: The list of updates available for install. - :vartype update_titles: list[str] - :ivar total_update_size_in_bytes: The total size of updates available for download in bytes. - :vartype total_update_size_in_bytes: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateSummary, self).__init__(**kwargs) - self.device_version_number = kwargs.get('device_version_number', None) - self.friendly_device_version_name = kwargs.get('friendly_device_version_name', None) - self.device_last_scanned_date_time = kwargs.get('device_last_scanned_date_time', None) - self.last_completed_scan_job_date_time = kwargs.get('last_completed_scan_job_date_time', None) - self.last_completed_download_job_date_time = None - self.last_completed_install_job_date_time = None - self.total_number_of_updates_available = None - self.total_number_of_updates_pending_download = None - self.total_number_of_updates_pending_install = None - self.reboot_behavior = None - self.ongoing_update_operation = None - self.in_progress_download_job_id = None - self.in_progress_install_job_id = None - self.in_progress_download_job_started_date_time = None - self.in_progress_install_job_started_date_time = None - self.update_titles = None - self.total_update_size_in_bytes = None - - -class UploadCertificateRequest(msrest.serialization.Model): - """The upload certificate request. - - All required parameters must be populated in order to send to Azure. - - :param authentication_type: The authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str - """ - - _validation = { - 'certificate': {'required': True}, - } - - _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) - self.authentication_type = kwargs.get('authentication_type', None) - self.certificate = kwargs['certificate'] - - -class UploadCertificateResponse(msrest.serialization.Model): - """The upload registration certificate response. - - All required parameters must be populated in order to send to Azure. - - :param auth_type: Specifies authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AuthenticationType - :param resource_id: Required. The resource ID of the Data Box Edge/Gateway device. - :type resource_id: str - :param aad_authority: Required. Azure Active Directory tenant authority. - :type aad_authority: str - :param aad_tenant_id: Required. Azure Active Directory tenant ID. - :type aad_tenant_id: str - :param service_principal_client_id: Required. Azure Active Directory service principal client - ID. - :type service_principal_client_id: str - :param service_principal_object_id: Required. Azure Active Directory service principal object - ID. - :type service_principal_object_id: str - :param azure_management_endpoint_audience: Required. The azure management endpoint audience. - :type azure_management_endpoint_audience: str - """ - - _validation = { - 'resource_id': {'required': True}, - 'aad_authority': {'required': True}, - 'aad_tenant_id': {'required': True}, - 'service_principal_client_id': {'required': True}, - 'service_principal_object_id': {'required': True}, - 'azure_management_endpoint_audience': {'required': True}, - } - - _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) - self.auth_type = kwargs.get('auth_type', None) - self.resource_id = kwargs['resource_id'] - self.aad_authority = kwargs['aad_authority'] - self.aad_tenant_id = kwargs['aad_tenant_id'] - self.service_principal_client_id = kwargs['service_principal_client_id'] - self.service_principal_object_id = kwargs['service_principal_object_id'] - self.azure_management_endpoint_audience = kwargs['azure_management_endpoint_audience'] - - -class User(ARMBaseModel): - """Represents a user who has access to one or more shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret - :param share_access_rights: List of shares that the user has rights on. This field should not - be specified during user creation. - :type share_access_rights: list[~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessRight] - """ - - _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'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.encrypted_password = kwargs.get('encrypted_password', None) - self.share_access_rights = kwargs.get('share_access_rights', None) - - -class UserAccessRight(msrest.serialization.Model): - """The mapping between a particular user and the access type on the SMB share. - - All required parameters must be populated in order to send to Azure. - - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessType - """ - - _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) - self.user_id = kwargs['user_id'] - self.access_type = kwargs['access_type'] - - -class UserList(msrest.serialization.Model): - """Collection of users. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of users. - :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.User] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) - self.value = None - self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_models_py3.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_models_py3.py index 8ae27675c6ba..52cb5680c47a 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_models_py3.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,50 +8,52 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._data_box_edge_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Address(msrest.serialization.Model): +class Address(_serialization.Model): """The shipping address of the customer. All required parameters must be populated in order to send to Azure. - :param address_line1: Required. The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: Required. The postal code. - :type postal_code: str - :param city: Required. The city name. - :type city: str - :param state: Required. The state name. - :type state: str - :param country: Required. The country name. - :type country: str + :ivar address_line1: The address line1. Required. + :vartype address_line1: str + :ivar address_line2: The address line2. + :vartype address_line2: str + :ivar address_line3: The address line3. + :vartype address_line3: str + :ivar postal_code: The postal code. Required. + :vartype postal_code: str + :ivar city: The city name. Required. + :vartype city: str + :ivar state: The state name. Required. + :vartype state: str + :ivar country: The country name. Required. + :vartype country: str """ _validation = { - 'address_line1': {'required': True}, - 'postal_code': {'required': True}, - 'city': {'required': True}, - 'state': {'required': True}, - 'country': {'required': True}, + "address_line1": {"required": True}, + "postal_code": {"required": True}, + "city": {"required": True}, + "state": {"required": True}, + "country": {"required": True}, } _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, + "address_line1": {"key": "addressLine1", "type": "str"}, + "address_line2": {"key": "addressLine2", "type": "str"}, + "address_line3": {"key": "addressLine3", "type": "str"}, + "postal_code": {"key": "postalCode", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "country": {"key": "country", "type": "str"}, } def __init__( @@ -65,7 +68,23 @@ def __init__( address_line3: Optional[str] = None, **kwargs ): - super(Address, self).__init__(**kwargs) + """ + :keyword address_line1: The address line1. Required. + :paramtype address_line1: str + :keyword address_line2: The address line2. + :paramtype address_line2: str + :keyword address_line3: The address line3. + :paramtype address_line3: str + :keyword postal_code: The postal code. Required. + :paramtype postal_code: str + :keyword city: The city name. Required. + :paramtype city: str + :keyword state: The state name. Required. + :paramtype state: str + :keyword country: The country name. Required. + :paramtype country: str + """ + super().__init__(**kwargs) self.address_line1 = address_line1 self.address_line2 = address_line2 self.address_line3 = address_line3 @@ -75,7 +94,7 @@ def __init__( self.country = country -class ARMBaseModel(msrest.serialization.Model): +class ARMBaseModel(_serialization.Model): """Represents the base class for all object models. Variables are only populated by the server, and will be ignored when sending a request. @@ -89,22 +108,20 @@ class ARMBaseModel(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -129,7 +146,7 @@ class Alert(ARMBaseModel): :vartype appeared_at_date_time: ~datetime.datetime :ivar recommendation: Alert recommendation. :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", + :ivar severity: Severity of the alert. Known values are: "Informational", "Warning", and "Critical". :vartype severity: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AlertSeverity :ivar error_details: Error details of the alert. @@ -139,36 +156,34 @@ class Alert(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "title": {"readonly": True}, + "alert_type": {"readonly": True}, + "appeared_at_date_time": {"readonly": True}, + "recommendation": {"readonly": True}, + "severity": {"readonly": True}, + "error_details": {"readonly": True}, + "detailed_information": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "title": {"key": "properties.title", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "appeared_at_date_time": {"key": "properties.appearedAtDateTime", "type": "iso-8601"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "error_details": {"key": "properties.errorDetails", "type": "AlertErrorDetails"}, + "detailed_information": {"key": "properties.detailedInformation", "type": "{str}"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.title = None self.alert_type = None self.appeared_at_date_time = None @@ -178,7 +193,7 @@ def __init__( self.detailed_information = None -class AlertErrorDetails(msrest.serialization.Model): +class AlertErrorDetails(_serialization.Model): """Error details for the alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -192,28 +207,26 @@ class AlertErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, + "error_code": {"readonly": True}, + "error_message": {"readonly": True}, + "occurrences": {"readonly": True}, } _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "occurrences": {"key": "occurrences", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_code = None self.error_message = None self.occurrences = None -class AlertList(msrest.serialization.Model): +class AlertList(_serialization.Model): """Collection of alerts. Variables are only populated by the server, and will be ignored when sending a request. @@ -225,112 +238,121 @@ class AlertList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class AsymmetricEncryptedSecret(msrest.serialization.Model): +class AsymmetricEncryptedSecret(_serialization.Model): """Represent the secrets intended for encryption with asymmetric key pair. All required parameters must be populated in order to send to Azure. - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + :ivar value: The value of the secret. Required. + :vartype value: str + :ivar encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or + :vartype encryption_cert_thumbprint: str + :ivar encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values are: + "None", "AES256", and "RSAES_PKCS1_v_1_5". + :vartype encryption_algorithm: str or ~azure.mgmt.databoxedge.v2019_07_01.models.EncryptionAlgorithm """ _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, + "value": {"required": True}, + "encryption_algorithm": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "encryption_cert_thumbprint": {"key": "encryptionCertThumbprint", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, } def __init__( self, *, value: str, - encryption_algorithm: Union[str, "EncryptionAlgorithm"], + encryption_algorithm: Union[str, "_models.EncryptionAlgorithm"], encryption_cert_thumbprint: Optional[str] = None, **kwargs ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) + """ + :keyword value: The value of the secret. Required. + :paramtype value: str + :keyword encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :paramtype encryption_cert_thumbprint: str + :keyword encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values + are: "None", "AES256", and "RSAES_PKCS1_v_1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.EncryptionAlgorithm + """ + super().__init__(**kwargs) self.value = value self.encryption_cert_thumbprint = encryption_cert_thumbprint self.encryption_algorithm = encryption_algorithm -class Authentication(msrest.serialization.Model): +class Authentication(_serialization.Model): """Authentication mechanism for IoT devices. - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2019_07_01.models.SymmetricKey + :ivar symmetric_key: Symmetric key for authentication. + :vartype symmetric_key: ~azure.mgmt.databoxedge.v2019_07_01.models.SymmetricKey """ _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, + "symmetric_key": {"key": "symmetricKey", "type": "SymmetricKey"}, } - def __init__( - self, - *, - symmetric_key: Optional["SymmetricKey"] = None, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) + def __init__(self, *, symmetric_key: Optional["_models.SymmetricKey"] = None, **kwargs): + """ + :keyword symmetric_key: Symmetric key for authentication. + :paramtype symmetric_key: ~azure.mgmt.databoxedge.v2019_07_01.models.SymmetricKey + """ + super().__init__(**kwargs) self.symmetric_key = symmetric_key -class AzureContainerInfo(msrest.serialization.Model): +class AzureContainerInfo(_serialization.Model): """Azure container mapping of the endpoint. All required parameters must be populated in order to send to Azure. - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AzureContainerDataFormat + :ivar storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :vartype storage_account_credential_id: str + :ivar container_name: Container name (Based on the data format specified, this represents the + name of Azure Files/Page blob/Block blob). Required. + :vartype container_name: str + :ivar data_format: Storage format used for the file represented by the share. Required. Known + values are: "BlockBlob", "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.AzureContainerDataFormat """ _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, + "storage_account_credential_id": {"required": True}, + "container_name": {"required": True}, + "data_format": {"required": True}, } _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, + "storage_account_credential_id": {"key": "storageAccountCredentialId", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "data_format": {"key": "dataFormat", "type": "str"}, } def __init__( @@ -338,10 +360,22 @@ def __init__( *, storage_account_credential_id: str, container_name: str, - data_format: Union[str, "AzureContainerDataFormat"], - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) + data_format: Union[str, "_models.AzureContainerDataFormat"], + **kwargs + ): + """ + :keyword storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :paramtype storage_account_credential_id: str + :keyword container_name: Container name (Based on the data format specified, this represents + the name of Azure Files/Page blob/Block blob). Required. + :paramtype container_name: str + :keyword data_format: Storage format used for the file represented by the share. Required. + Known values are: "BlockBlob", "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.storage_account_credential_id = storage_account_credential_id self.container_name = container_name self.data_format = data_format @@ -360,53 +394,57 @@ class BandwidthSchedule(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2019_07_01.models.DayOfWeek] + :ivar start: The start time of the schedule in UTC. Required. + :vartype start: str + :ivar stop: The stop time of the schedule in UTC. Required. + :vartype stop: str + :ivar rate_in_mbps: The bandwidth rate in Mbps. Required. + :vartype rate_in_mbps: int + :ivar days: The days of the week when this schedule is applicable. Required. + :vartype days: list[str or ~azure.mgmt.databoxedge.v2019_07_01.models.DayOfWeek] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - *, - start: str, - stop: str, - rate_in_mbps: int, - days: List[Union[str, "DayOfWeek"]], - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "start": {"required": True}, + "stop": {"required": True}, + "rate_in_mbps": {"required": True}, + "days": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "start": {"key": "properties.start", "type": "str"}, + "stop": {"key": "properties.stop", "type": "str"}, + "rate_in_mbps": {"key": "properties.rateInMbps", "type": "int"}, + "days": {"key": "properties.days", "type": "[str]"}, + } + + def __init__( + self, *, start: str, stop: str, rate_in_mbps: int, days: List[Union[str, "_models.DayOfWeek"]], **kwargs + ): + """ + :keyword start: The start time of the schedule in UTC. Required. + :paramtype start: str + :keyword stop: The stop time of the schedule in UTC. Required. + :paramtype stop: str + :keyword rate_in_mbps: The bandwidth rate in Mbps. Required. + :paramtype rate_in_mbps: int + :keyword days: The days of the week when this schedule is applicable. Required. + :paramtype days: list[str or ~azure.mgmt.databoxedge.v2019_07_01.models.DayOfWeek] + """ + super().__init__(**kwargs) self.start = start self.stop = stop self.rate_in_mbps = rate_in_mbps self.days = days -class BandwidthSchedulesList(msrest.serialization.Model): +class BandwidthSchedulesList(_serialization.Model): """The collection of bandwidth schedules. Variables are only populated by the server, and will be ignored when sending a request. @@ -418,75 +456,76 @@ class BandwidthSchedulesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BandwidthSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ClientAccessRight(msrest.serialization.Model): +class ClientAccessRight(_serialization.Model): """The mapping between a particular client IP and the type of access client has on the NFS share. All required parameters must be populated in order to send to Azure. - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ClientPermissionType + :ivar client: IP of the client. Required. + :vartype client: str + :ivar access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :vartype access_permission: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.ClientPermissionType """ _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, + "client": {"required": True}, + "access_permission": {"required": True}, } _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, + "client": {"key": "client", "type": "str"}, + "access_permission": {"key": "accessPermission", "type": "str"}, } - def __init__( - self, - *, - client: str, - access_permission: Union[str, "ClientPermissionType"], - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) + def __init__(self, *, client: str, access_permission: Union[str, "_models.ClientPermissionType"], **kwargs): + """ + :keyword client: IP of the client. Required. + :paramtype client: str + :keyword access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :paramtype access_permission: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.ClientPermissionType + """ + super().__init__(**kwargs) self.client = client self.access_permission = access_permission -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2019_07_01.models.CloudErrorBody] + :vartype message: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.databoxedge.v2019_07_01.models.CloudErrorBody] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -494,61 +533,73 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.databoxedge.v2019_07_01.models.CloudErrorBody] + """ + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class ContactDetails(msrest.serialization.Model): +class ContactDetails(_serialization.Model): """Contains all the contact details of the customer. All required parameters must be populated in order to send to Azure. - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] + :ivar contact_person: The contact person name. Required. + :vartype contact_person: str + :ivar company_name: The name of the company. Required. + :vartype company_name: str + :ivar phone: The phone number. Required. + :vartype phone: str + :ivar email_list: The email list. Required. + :vartype email_list: list[str] """ _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - *, - contact_person: str, - company_name: str, - phone: str, - email_list: List[str], - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) + "contact_person": {"required": True}, + "company_name": {"required": True}, + "phone": {"required": True}, + "email_list": {"required": True}, + } + + _attribute_map = { + "contact_person": {"key": "contactPerson", "type": "str"}, + "company_name": {"key": "companyName", "type": "str"}, + "phone": {"key": "phone", "type": "str"}, + "email_list": {"key": "emailList", "type": "[str]"}, + } + + def __init__(self, *, contact_person: str, company_name: str, phone: str, email_list: List[str], **kwargs): + """ + :keyword contact_person: The contact person name. Required. + :paramtype contact_person: str + :keyword company_name: The name of the company. Required. + :paramtype company_name: str + :keyword phone: The phone number. Required. + :paramtype phone: str + :keyword email_list: The email list. Required. + :paramtype email_list: list[str] + """ + super().__init__(**kwargs) self.contact_person = contact_person self.company_name = company_name self.phone = phone self.email_list = email_list -class DataBoxEdgeDevice(ARMBaseModel): +class DataBoxEdgeDevice(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -561,34 +612,33 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure + :ivar location: The location of the device. This is a supported and registered Azure geographical region (for example, West US, East US, or Southeast Asia). The geographical region of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2019_07_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or + specified on update, the request will succeed. Required. + :vartype location: str + :ivar tags: The list of tags that describe the device. These tags can be used to view and group + this device (across resource groups). + :vartype tags: dict[str, str] + :ivar sku: The SKU type. + :vartype sku: ~azure.mgmt.databoxedge.v2019_07_01.models.Sku + :ivar etag: The etag for the devices. + :vartype etag: str + :ivar data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known values + are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :vartype data_box_edge_device_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDeviceStatus :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. :vartype serial_number: str - :param description: The Description of the Data Box Edge/Gateway device. - :type description: str - :param model_description: The description of the Data Box Edge/Gateway device model. - :type model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". + :ivar description: The Description of the Data Box Edge/Gateway device. + :vartype description: str + :ivar model_description: The description of the Data Box Edge/Gateway device model. + :vartype model_description: str + :ivar device_type: The type of the Data Box Edge/Gateway device. "DataBoxEdgeDevice" :vartype device_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.DeviceType - :param friendly_name: The Data Box Edge/Gateway device name. - :type friendly_name: str + :ivar friendly_name: The Data Box Edge/Gateway device name. + :vartype friendly_name: str :ivar culture: The Data Box Edge/Gateway device culture. :vartype culture: str :ivar device_model: The Data Box Edge/Gateway device model. @@ -596,7 +646,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :ivar device_software_version: The Data Box Edge/Gateway device software version. :vartype device_software_version: str :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long + :vartype device_local_capacity: int :ivar time_zone: The Data Box Edge/Gateway device timezone. :vartype time_zone: str :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). @@ -609,44 +659,44 @@ class DataBoxEdgeDevice(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'serial_number': {'readonly': True}, - 'device_type': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "serial_number": {"readonly": True}, + "device_type": {"readonly": True}, + "culture": {"readonly": True}, + "device_model": {"readonly": True}, + "device_software_version": {"readonly": True}, + "device_local_capacity": {"readonly": True}, + "time_zone": {"readonly": True}, + "device_hcs_version": {"readonly": True}, + "configured_role_types": {"readonly": True}, + "node_count": {"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}"}, + "sku": {"key": "sku", "type": "Sku"}, + "etag": {"key": "etag", "type": "str"}, + "data_box_edge_device_status": {"key": "properties.dataBoxEdgeDeviceStatus", "type": "str"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "model_description": {"key": "properties.modelDescription", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "culture": {"key": "properties.culture", "type": "str"}, + "device_model": {"key": "properties.deviceModel", "type": "str"}, + "device_software_version": {"key": "properties.deviceSoftwareVersion", "type": "str"}, + "device_local_capacity": {"key": "properties.deviceLocalCapacity", "type": "int"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "device_hcs_version": {"key": "properties.deviceHcsVersion", "type": "str"}, + "configured_role_types": {"key": "properties.configuredRoleTypes", "type": "[str]"}, + "node_count": {"key": "properties.nodeCount", "type": "int"}, } def __init__( @@ -654,15 +704,40 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, etag: Optional[str] = None, - data_box_edge_device_status: Optional[Union[str, "DataBoxEdgeDeviceStatus"]] = None, + data_box_edge_device_status: Optional[Union[str, "_models.DataBoxEdgeDeviceStatus"]] = None, description: Optional[str] = None, model_description: Optional[str] = None, friendly_name: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) + """ + :keyword location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :paramtype location: str + :keyword tags: The list of tags that describe the device. These tags can be used to view and + group this device (across resource groups). + :paramtype tags: dict[str, str] + :keyword sku: The SKU type. + :paramtype sku: ~azure.mgmt.databoxedge.v2019_07_01.models.Sku + :keyword etag: The etag for the devices. + :paramtype etag: str + :keyword data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known + values are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :paramtype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDeviceStatus + :keyword description: The Description of the Data Box Edge/Gateway device. + :paramtype description: str + :keyword model_description: The description of the Data Box Edge/Gateway device model. + :paramtype model_description: str + :keyword friendly_name: The Data Box Edge/Gateway device name. + :paramtype friendly_name: str + """ + super().__init__(**kwargs) self.location = location self.tags = tags self.sku = sku @@ -694,45 +769,48 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to + :ivar encryption_key_thumbprint: The digital signature of encrypted certificate. + :vartype encryption_key_thumbprint: str + :ivar encryption_key: The public part of the encryption certificate. Client uses this to encrypt any secret. - :type encryption_key: str + :vartype encryption_key: str :ivar resource_key: The Resource ID of the Resource. :vartype resource_key: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_key": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encryption_key_thumbprint": {"key": "properties.encryptionKeyThumbprint", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "str"}, + "resource_key": {"key": "properties.resourceKey", "type": "str"}, } def __init__( - self, - *, - encryption_key_thumbprint: Optional[str] = None, - encryption_key: Optional[str] = None, - **kwargs + self, *, encryption_key_thumbprint: Optional[str] = None, encryption_key: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) + """ + :keyword encryption_key_thumbprint: The digital signature of encrypted certificate. + :paramtype encryption_key_thumbprint: str + :keyword encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :paramtype encryption_key: str + """ + super().__init__(**kwargs) self.encryption_key_thumbprint = encryption_key_thumbprint self.encryption_key = encryption_key self.resource_key = None -class DataBoxEdgeDeviceList(msrest.serialization.Model): +class DataBoxEdgeDeviceList(_serialization.Model): """The collection of Data Box Edge/Gateway devices. Variables are only populated by the server, and will be ignored when sending a request. @@ -744,50 +822,47 @@ class DataBoxEdgeDeviceList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevicePatch(msrest.serialization.Model): +class DataBoxEdgeDevicePatch(_serialization.Model): """The Data Box Edge/Gateway device patch. - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] + :ivar tags: The tags attached to the Data Box Edge/Gateway resource. + :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: The tags attached to the Data Box Edge/Gateway resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) self.tags = tags class Trigger(ARMBaseModel): """Trigger details. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FileEventTrigger, PeriodicTimerEventTrigger Variables are only populated by the server, and will be ignored when sending a request. @@ -799,35 +874,30 @@ class Trigger(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.TriggerEventType + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.TriggerEventType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } + _subtype_map = {"kind": {"FileEvent": "FileEventTrigger", "PeriodicTimerEvent": "PeriodicTimerEventTrigger"}} - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.kind = 'Trigger' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None class FileEventTrigger(Trigger): @@ -843,105 +913,113 @@ class FileEventTrigger(Trigger): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2019_07_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2019_07_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.TriggerEventType + :ivar source_info: File event source details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2019_07_01.models.FileSourceInfo + :ivar sink_info: Role sink info. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2019_07_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "FileSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "FileSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.FileSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str + """ + :keyword source_info: File event source details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2019_07_01.models.FileSourceInfo + :keyword sink_info: Role sink info. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2019_07_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "FileEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class FileSourceInfo(msrest.serialization.Model): +class FileSourceInfo(_serialization.Model): """File source details. All required parameters must be populated in order to send to Azure. - :param share_id: Required. File share ID. - :type share_id: str + :ivar share_id: File share ID. Required. + :vartype share_id: str """ _validation = { - 'share_id': {'required': True}, + "share_id": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: File share ID. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id -class IoTDeviceInfo(msrest.serialization.Model): +class IoTDeviceInfo(_serialization.Model): """Metadata of IoT device/IoT Edge device to be configured. All required parameters must be populated in order to send to Azure. - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id of the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: IoT device authentication info. - :type authentication: ~azure.mgmt.databoxedge.v2019_07_01.models.Authentication + :ivar device_id: ID of the IoT device/edge device. Required. + :vartype device_id: str + :ivar io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :vartype io_t_host_hub: str + :ivar io_t_host_hub_id: Id of the IoT hub associated to the device. + :vartype io_t_host_hub_id: str + :ivar authentication: IoT device authentication info. + :vartype authentication: ~azure.mgmt.databoxedge.v2019_07_01.models.Authentication """ _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, + "device_id": {"required": True}, + "io_t_host_hub": {"required": True}, } _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, + "device_id": {"key": "deviceId", "type": "str"}, + "io_t_host_hub": {"key": "ioTHostHub", "type": "str"}, + "io_t_host_hub_id": {"key": "ioTHostHubId", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, } def __init__( @@ -950,10 +1028,20 @@ def __init__( device_id: str, io_t_host_hub: str, io_t_host_hub_id: Optional[str] = None, - authentication: Optional["Authentication"] = None, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) + authentication: Optional["_models.Authentication"] = None, + **kwargs + ): + """ + :keyword device_id: ID of the IoT device/edge device. Required. + :paramtype device_id: str + :keyword io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :paramtype io_t_host_hub: str + :keyword io_t_host_hub_id: Id of the IoT hub associated to the device. + :paramtype io_t_host_hub_id: str + :keyword authentication: IoT device authentication info. + :paramtype authentication: ~azure.mgmt.databoxedge.v2019_07_01.models.Authentication + """ + super().__init__(**kwargs) self.device_id = device_id self.io_t_host_hub = io_t_host_hub self.io_t_host_hub_id = io_t_host_hub_id @@ -963,8 +1051,8 @@ def __init__( class Role(ARMBaseModel): """Compute role. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: IoTRole. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + IoTRole Variables are only populated by the server, and will be ignored when sending a request. @@ -976,35 +1064,30 @@ class Role(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", and "Cognitive". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleTypes """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'IOT': 'IoTRole'} - } + _subtype_map = {"kind": {"IOT": "IoTRole"}} - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None class IoTRole(Role): @@ -1020,54 +1103,68 @@ class IoTRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleTypes - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", and "Cognitive". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleTypes + :ivar host_platform: Host OS supported by the IoT role. Known values are: "Windows" and "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2019_07_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2019_07_01.models.PlatformType + :ivar io_t_device_details: IoT device metadata to which data box edge device needs to be connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2019_07_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_07_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2019_07_01.models.MountPointMap] - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleStatus + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2019_07_01.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_07_01.models.IoTDeviceInfo + :ivar share_mappings: Mount points of shares in role(s). + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2019_07_01.models.MountPointMap] + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - io_t_device_details: Optional["IoTDeviceInfo"] = None, - io_t_edge_device_details: Optional["IoTDeviceInfo"] = None, - share_mappings: Optional[List["MountPointMap"]] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + io_t_device_details: Optional["_models.IoTDeviceInfo"] = None, + io_t_edge_device_details: Optional["_models.IoTDeviceInfo"] = None, + share_mappings: Optional[List["_models.MountPointMap"]] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, + **kwargs + ): + """ + :keyword host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :paramtype host_platform: str or ~azure.mgmt.databoxedge.v2019_07_01.models.PlatformType + :keyword io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :paramtype io_t_device_details: ~azure.mgmt.databoxedge.v2019_07_01.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT role needs to be + configured. + :paramtype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_07_01.models.IoTDeviceInfo + :keyword share_mappings: Mount points of shares in role(s). + :paramtype share_mappings: list[~azure.mgmt.databoxedge.v2019_07_01.models.MountPointMap] + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "IOT" self.host_platform = host_platform self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details @@ -1075,7 +1172,7 @@ def __init__( self.role_status = role_status -class Ipv4Config(msrest.serialization.Model): +class Ipv4Config(_serialization.Model): """Details related to the IPv4 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1089,28 +1186,26 @@ class Ipv4Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "subnet": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.subnet = None self.gateway = None -class Ipv6Config(msrest.serialization.Model): +class Ipv6Config(_serialization.Model): """Details related to the IPv6 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1124,28 +1219,26 @@ class Ipv6Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "prefix_length": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "int"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.prefix_length = None self.gateway = None -class Job(msrest.serialization.Model): +class Job(_serialization.Model): # pylint: disable=too-many-instance-attributes """A device job. Variables are only populated by the server, and will be ignored when sending a request. @@ -1156,8 +1249,8 @@ class Job(msrest.serialization.Model): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar status: The current status of the job. Known values are: "Invalid", "Running", + "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.JobStatus :ivar start_time: The UTC date and time at which the job started. :vartype start_time: ~datetime.datetime @@ -1167,13 +1260,13 @@ class Job(msrest.serialization.Model): :vartype percent_complete: int :ivar error: The error details. :vartype error: ~azure.mgmt.databoxedge.v2019_07_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare". + :ivar job_type: The type of the job. Known values are: "Invalid", "ScanForUpdates", + "DownloadUpdates", "InstallUpdates", and "RefreshShare". :vartype job_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", + :ivar current_stage: Current stage of the update operation. Known values are: "Unknown", "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". + "Success", "Failure", "RescanStarted", "RescanComplete", and "RescanFailed". :vartype current_stage: str or ~azure.mgmt.databoxedge.v2019_07_01.models.UpdateOperationStage :ivar download_progress: The download progress. :vartype download_progress: ~azure.mgmt.databoxedge.v2019_07_01.models.UpdateDownloadProgress @@ -1186,55 +1279,55 @@ class Job(msrest.serialization.Model): :vartype error_manifest_file: str :ivar share_id: ARM ID of the share that was refreshed. :vartype share_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the + :ivar folder: If only subfolders need to be refreshed, then the subfolder path inside the share. (The path is empty if there are no subfolders.). - :type folder: str + :vartype folder: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'share_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'share_id': {'key': 'properties.shareId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - *, - folder: Optional[str] = None, - **kwargs - ): - super(Job, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "error": {"readonly": True}, + "job_type": {"readonly": True}, + "current_stage": {"readonly": True}, + "download_progress": {"readonly": True}, + "install_progress": {"readonly": True}, + "total_refresh_errors": {"readonly": True}, + "error_manifest_file": {"readonly": True}, + "share_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "error": {"key": "error", "type": "JobErrorDetails"}, + "job_type": {"key": "properties.jobType", "type": "str"}, + "current_stage": {"key": "properties.currentStage", "type": "str"}, + "download_progress": {"key": "properties.downloadProgress", "type": "UpdateDownloadProgress"}, + "install_progress": {"key": "properties.installProgress", "type": "UpdateInstallProgress"}, + "total_refresh_errors": {"key": "properties.totalRefreshErrors", "type": "int"}, + "error_manifest_file": {"key": "properties.errorManifestFile", "type": "str"}, + "share_id": {"key": "properties.shareId", "type": "str"}, + "folder": {"key": "properties.folder", "type": "str"}, + } + + def __init__(self, *, folder: Optional[str] = None, **kwargs): + """ + :keyword folder: If only subfolders need to be refreshed, then the subfolder path inside the + share. (The path is empty if there are no subfolders.). + :paramtype folder: str + """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1253,7 +1346,7 @@ def __init__( self.folder = folder -class JobErrorDetails(msrest.serialization.Model): +class JobErrorDetails(_serialization.Model): """The job error information containing the list of job errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -1267,28 +1360,26 @@ class JobErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "error_details": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "error_details": {"key": "errorDetails", "type": "[JobErrorItem]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_details = None self.code = None self.message = None -class JobErrorItem(msrest.serialization.Model): +class JobErrorItem(_serialization.Model): """The job error items. Variables are only populated by the server, and will be ignored when sending a request. @@ -1302,42 +1393,40 @@ class JobErrorItem(msrest.serialization.Model): """ _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "recommendations": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "recommendations": {"key": "recommendations", "type": "[str]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.recommendations = None self.code = None self.message = None -class MetricDimensionV1(msrest.serialization.Model): +class MetricDimensionV1(_serialization.Model): """Metric Dimension v1. - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the metrics dimension. + :vartype name: str + :ivar display_name: Display name of the metrics dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -1348,55 +1437,64 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(MetricDimensionV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metrics dimension. + :paramtype name: str + :keyword display_name: Display name of the metrics dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecificationV1(msrest.serialization.Model): +class MetricSpecificationV1(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric specification version 1. - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2019_07_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Description of the metric to be displayed. + :vartype display_description: str + :ivar unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :vartype unit: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricUnit + :ivar aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :vartype aggregation_type: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.MetricAggregationType + :ivar dimensions: Metric dimensions, other than default dimension which is resource. + :vartype dimensions: list[~azure.mgmt.databoxedge.v2019_07_01.models.MetricDimensionV1] + :ivar fill_gap_with_zero: Set true to fill the gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar category: Metric category. Known values are: "Capacity" and "Transaction". + :vartype category: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricCategory + :ivar resource_id_dimension_name_override: Resource name override. + :vartype resource_id_dimension_name_override: str + :ivar supported_time_grain_types: Support granularity of metrics. + :vartype supported_time_grain_types: list[str or ~azure.mgmt.databoxedge.v2019_07_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricAggregationType] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimensionV1]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, } def __init__( @@ -1405,17 +1503,46 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, display_description: Optional[str] = None, - unit: Optional[Union[str, "MetricUnit"]] = None, - aggregation_type: Optional[Union[str, "MetricAggregationType"]] = None, - dimensions: Optional[List["MetricDimensionV1"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, + dimensions: Optional[List["_models.MetricDimensionV1"]] = None, fill_gap_with_zero: Optional[bool] = None, - category: Optional[Union[str, "MetricCategory"]] = None, + category: Optional[Union[str, "_models.MetricCategory"]] = None, resource_id_dimension_name_override: Optional[str] = None, - supported_time_grain_types: Optional[List[Union[str, "TimeGrain"]]] = None, - supported_aggregation_types: Optional[List[Union[str, "MetricAggregationType"]]] = None, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) + supported_time_grain_types: Optional[List[Union[str, "_models.TimeGrain"]]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, + **kwargs + ): + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Description of the metric to be displayed. + :paramtype display_description: str + :keyword unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :paramtype unit: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricUnit + :keyword aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :paramtype aggregation_type: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.MetricAggregationType + :keyword dimensions: Metric dimensions, other than default dimension which is resource. + :paramtype dimensions: list[~azure.mgmt.databoxedge.v2019_07_01.models.MetricDimensionV1] + :keyword fill_gap_with_zero: Set true to fill the gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: Metric category. Known values are: "Capacity" and "Transaction". + :paramtype category: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MetricCategory + :keyword resource_id_dimension_name_override: Resource name override. + :paramtype resource_id_dimension_name_override: str + :keyword supported_time_grain_types: Support granularity of metrics. + :paramtype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2019_07_01.models.TimeGrain] + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2019_07_01.models.MetricAggregationType] + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1429,51 +1556,50 @@ def __init__( self.supported_aggregation_types = supported_aggregation_types -class MountPointMap(msrest.serialization.Model): +class MountPointMap(_serialization.Model): """The share mount point. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str + :ivar share_id: ID of the share mounted to the role VM. Required. + :vartype share_id: str :ivar role_id: ID of the role to which share is mounted. :vartype role_id: str :ivar mount_point: Mount point for the share. :vartype mount_point: str - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive". + :ivar role_type: Role type. Known values are: "IOT", "ASA", "Functions", and "Cognitive". :vartype role_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.RoleTypes """ _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'role_type': {'readonly': True}, + "share_id": {"required": True}, + "role_id": {"readonly": True}, + "mount_point": {"readonly": True}, + "role_type": {"readonly": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "mount_point": {"key": "mountPoint", "type": "str"}, + "role_type": {"key": "roleType", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: ID of the share mounted to the role VM. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id self.role_id = None self.mount_point = None self.role_type = None -class NetworkAdapter(msrest.serialization.Model): +class NetworkAdapter(_serialization.Model): # pylint: disable=too-many-instance-attributes """Represents the networkAdapter on a device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1493,16 +1619,18 @@ class NetworkAdapter(msrest.serialization.Model): :ivar mac_address: MAC address. :vartype mac_address: str :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". + :vartype link_speed: int + :ivar status: Value indicating whether this adapter is valid. Known values are: "Inactive" and + "Active". :vartype status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterDHCPStatus + :ivar rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :vartype rdma_status: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterRDMAStatus + :ivar dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :vartype dhcp_status: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterDHCPStatus :ivar ipv4_configuration: The IPv4 configuration of the network adapter. :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2019_07_01.models.Ipv4Config :ivar ipv6_configuration: The IPv6 configuration of the network adapter. @@ -1514,47 +1642,57 @@ class NetworkAdapter(msrest.serialization.Model): """ _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, + "adapter_id": {"readonly": True}, + "adapter_position": {"readonly": True}, + "index": {"readonly": True}, + "node_id": {"readonly": True}, + "network_adapter_name": {"readonly": True}, + "label": {"readonly": True}, + "mac_address": {"readonly": True}, + "link_speed": {"readonly": True}, + "status": {"readonly": True}, + "ipv4_configuration": {"readonly": True}, + "ipv6_configuration": {"readonly": True}, + "ipv6_link_local_address": {"readonly": True}, + "dns_servers": {"readonly": True}, + } + + _attribute_map = { + "adapter_id": {"key": "adapterId", "type": "str"}, + "adapter_position": {"key": "adapterPosition", "type": "NetworkAdapterPosition"}, + "index": {"key": "index", "type": "int"}, + "node_id": {"key": "nodeId", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "mac_address": {"key": "macAddress", "type": "str"}, + "link_speed": {"key": "linkSpeed", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "rdma_status": {"key": "rdmaStatus", "type": "str"}, + "dhcp_status": {"key": "dhcpStatus", "type": "str"}, + "ipv4_configuration": {"key": "ipv4Configuration", "type": "Ipv4Config"}, + "ipv6_configuration": {"key": "ipv6Configuration", "type": "Ipv6Config"}, + "ipv6_link_local_address": {"key": "ipv6LinkLocalAddress", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, } def __init__( self, *, - rdma_status: Optional[Union[str, "NetworkAdapterRDMAStatus"]] = None, - dhcp_status: Optional[Union[str, "NetworkAdapterDHCPStatus"]] = None, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) + rdma_status: Optional[Union[str, "_models.NetworkAdapterRDMAStatus"]] = None, + dhcp_status: Optional[Union[str, "_models.NetworkAdapterDHCPStatus"]] = None, + **kwargs + ): + """ + :keyword rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :paramtype rdma_status: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterRDMAStatus + :keyword dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :paramtype dhcp_status: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkAdapterDHCPStatus + """ + super().__init__(**kwargs) self.adapter_id = None self.adapter_position = None self.index = None @@ -1572,32 +1710,30 @@ def __init__( self.dns_servers = None -class NetworkAdapterPosition(msrest.serialization.Model): +class NetworkAdapterPosition(_serialization.Model): """The network adapter position. Variables are only populated by the server, and will be ignored when sending a request. - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". + :ivar network_group: The network group. Known values are: "None", "NonRDMA", and "RDMA". :vartype network_group: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkGroup :ivar port: The port. :vartype port: int """ _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, + "network_group": {"readonly": True}, + "port": {"readonly": True}, } _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, + "network_group": {"key": "networkGroup", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_group = None self.port = None @@ -1618,89 +1754,85 @@ class NetworkSettings(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "network_adapters": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "network_adapters": {"key": "properties.networkAdapters", "type": "[NetworkAdapter]"}, } - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_adapters = None class Node(ARMBaseModel): """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str + Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node + Multi-node Edge devices will have more than 1 nodes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar node_status: The current status of the individual node. Known values are: "Unknown", + "Up", "Down", "Rebooting", and "ShuttingDown". + :vartype node_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.NodeStatus + :ivar node_chassis_serial_number: Serial number of the Chassis. + :vartype node_chassis_serial_number: str + :ivar node_serial_number: Serial number of the individual node. + :vartype node_serial_number: str + :ivar node_display_name: Display Name of the individual node. + :vartype node_display_name: str + :ivar node_friendly_software_version: Friendly software version name that is currently + installed on the node. + :vartype node_friendly_software_version: str + :ivar node_hcs_version: HCS version that is currently installed on the node. + :vartype node_hcs_version: str + :ivar node_instance_id: Guid instance id of the node. + :vartype node_instance_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "node_status": {"readonly": True}, + "node_chassis_serial_number": {"readonly": True}, + "node_serial_number": {"readonly": True}, + "node_display_name": {"readonly": True}, + "node_friendly_software_version": {"readonly": True}, + "node_hcs_version": {"readonly": True}, + "node_instance_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "node_status": {"key": "properties.nodeStatus", "type": "str"}, + "node_chassis_serial_number": {"key": "properties.nodeChassisSerialNumber", "type": "str"}, + "node_serial_number": {"key": "properties.nodeSerialNumber", "type": "str"}, + "node_display_name": {"key": "properties.nodeDisplayName", "type": "str"}, + "node_friendly_software_version": {"key": "properties.nodeFriendlySoftwareVersion", "type": "str"}, + "node_hcs_version": {"key": "properties.nodeHcsVersion", "type": "str"}, + "node_instance_id": {"key": "properties.nodeInstanceId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.node_status = None self.node_chassis_serial_number = None self.node_serial_number = None @@ -1710,7 +1842,7 @@ def __init__( self.node_instance_id = None -class NodeList(msrest.serialization.Model): +class NodeList(_serialization.Model): """Collection of Nodes. Variables are only populated by the server, and will be ignored when sending a request. @@ -1720,75 +1852,84 @@ class NodeList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, + "value": {"key": "value", "type": "[Node]"}, } - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operations. - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2019_07_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2019_07_01.models.ServiceSpecification + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties displayed for the operation. + :vartype display: ~azure.mgmt.databoxedge.v2019_07_01.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar service_specification: Service specification. + :vartype service_specification: ~azure.mgmt.databoxedge.v2019_07_01.models.ServiceSpecification """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): - super(Operation, self).__init__(**kwargs) + service_specification: Optional["_models.ServiceSpecification"] = None, + **kwargs + ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties displayed for the operation. + :paramtype display: ~azure.mgmt.databoxedge.v2019_07_01.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword service_specification: Service specification. + :paramtype service_specification: + ~azure.mgmt.databoxedge.v2019_07_01.models.ServiceSpecification + """ + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display properties. - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: The type of resource in which the operation is performed. + :vartype resource: str + :ivar operation: Operation to be performed on the resource. + :vartype operation: str + :ivar description: Description of the operation to be performed. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1800,41 +1941,51 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: The type of resource in which the operation is performed. + :paramtype resource: str + :keyword operation: Operation to be performed on the resource. + :paramtype operation: str + :keyword description: Description of the operation to be performed. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsList(msrest.serialization.Model): +class OperationsList(_serialization.Model): """The list of operations used for the discovery of available provider operations. All required parameters must be populated in order to send to Azure. - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar value: The value. Required. + :vartype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Operation] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["Operation"], - next_link: Optional[str] = None, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The value. Required. + :paramtype value: list[~azure.mgmt.databoxedge.v2019_07_01.models.Operation] + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1850,12 +2001,12 @@ class Order(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2019_07_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2019_07_01.models.Address - :param current_status: Current status of the order. - :type current_status: ~azure.mgmt.databoxedge.v2019_07_01.models.OrderStatus + :ivar contact_information: The contact details. + :vartype contact_information: ~azure.mgmt.databoxedge.v2019_07_01.models.ContactDetails + :ivar shipping_address: The shipping address. + :vartype shipping_address: ~azure.mgmt.databoxedge.v2019_07_01.models.Address + :ivar current_status: Current status of the order. + :vartype current_status: ~azure.mgmt.databoxedge.v2019_07_01.models.OrderStatus :ivar order_history: List of status changes in the order. :vartype order_history: list[~azure.mgmt.databoxedge.v2019_07_01.models.OrderStatus] :ivar serial_number: Serial number of the device. @@ -1869,37 +2020,45 @@ class Order(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "order_history": {"readonly": True}, + "serial_number": {"readonly": True}, + "delivery_tracking_info": {"readonly": True}, + "return_tracking_info": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "contact_information": {"key": "properties.contactInformation", "type": "ContactDetails"}, + "shipping_address": {"key": "properties.shippingAddress", "type": "Address"}, + "current_status": {"key": "properties.currentStatus", "type": "OrderStatus"}, + "order_history": {"key": "properties.orderHistory", "type": "[OrderStatus]"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "delivery_tracking_info": {"key": "properties.deliveryTrackingInfo", "type": "[TrackingInfo]"}, + "return_tracking_info": {"key": "properties.returnTrackingInfo", "type": "[TrackingInfo]"}, } def __init__( self, *, - contact_information: Optional["ContactDetails"] = None, - shipping_address: Optional["Address"] = None, - current_status: Optional["OrderStatus"] = None, - **kwargs - ): - super(Order, self).__init__(**kwargs) + contact_information: Optional["_models.ContactDetails"] = None, + shipping_address: Optional["_models.Address"] = None, + current_status: Optional["_models.OrderStatus"] = None, + **kwargs + ): + """ + :keyword contact_information: The contact details. + :paramtype contact_information: ~azure.mgmt.databoxedge.v2019_07_01.models.ContactDetails + :keyword shipping_address: The shipping address. + :paramtype shipping_address: ~azure.mgmt.databoxedge.v2019_07_01.models.Address + :keyword current_status: Current status of the order. + :paramtype current_status: ~azure.mgmt.databoxedge.v2019_07_01.models.OrderStatus + """ + super().__init__(**kwargs) self.contact_information = contact_information self.shipping_address = shipping_address self.current_status = current_status @@ -1909,7 +2068,7 @@ def __init__( self.return_tracking_info = None -class OrderList(msrest.serialization.Model): +class OrderList(_serialization.Model): """List of order entities. Variables are only populated by the server, and will be ignored when sending a request. @@ -1921,61 +2080,62 @@ class OrderList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Order]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OrderStatus(msrest.serialization.Model): +class OrderStatus(_serialization.Model): """Represents a single status change. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft". - :type status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.OrderState + :ivar status: Status of the order as per the allowed status types. Required. Known values are: + "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", and "CollectedAtMicrosoft". + :vartype status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.OrderState :ivar update_date_time: Time of status update. :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str + :ivar comments: Comments related to this status change. + :vartype comments: str """ _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, + "status": {"required": True}, + "update_date_time": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + "comments": {"key": "comments", "type": "str"}, } - def __init__( - self, - *, - status: Union[str, "OrderState"], - comments: Optional[str] = None, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) + def __init__(self, *, status: Union[str, "_models.OrderState"], comments: Optional[str] = None, **kwargs): + """ + :keyword status: Status of the order as per the allowed status types. Required. Known values + are: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", and "CollectedAtMicrosoft". + :paramtype status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.OrderState + :keyword comments: Comments related to this status change. + :paramtype comments: str + """ + super().__init__(**kwargs) self.status = status self.update_date_time = None self.comments = comments @@ -1994,117 +2154,130 @@ class PeriodicTimerEventTrigger(Trigger): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2019_07_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2019_07_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_07_01.models.TriggerEventType + :ivar source_info: Periodic timer details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2019_07_01.models.PeriodicTimerSourceInfo + :ivar sink_info: Role Sink information. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2019_07_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "PeriodicTimerSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "PeriodicTimerSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.PeriodicTimerSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str + """ + :keyword source_info: Periodic timer details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2019_07_01.models.PeriodicTimerSourceInfo + :keyword sink_info: Role Sink information. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2019_07_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "PeriodicTimerEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class PeriodicTimerSourceInfo(msrest.serialization.Model): +class PeriodicTimerSourceInfo(_serialization.Model): """Periodic timer event source. All required parameters must be populated in order to send to Azure. - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str + :ivar start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :vartype start_time: ~datetime.datetime + :ivar schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :vartype schedule: str + :ivar topic: Topic where periodic events are published to IoT device. + :vartype topic: str """ _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, + "start_time": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "schedule": {"key": "schedule", "type": "str"}, + "topic": {"key": "topic", "type": "str"}, } - def __init__( - self, - *, - start_time: datetime.datetime, - schedule: str, - topic: Optional[str] = None, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) + def __init__(self, *, start_time: datetime.datetime, schedule: str, topic: Optional[str] = None, **kwargs): + """ + :keyword start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :paramtype start_time: ~datetime.datetime + :keyword schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :paramtype schedule: str + :keyword topic: Topic where periodic events are published to IoT device. + :paramtype topic: str + """ + super().__init__(**kwargs) self.start_time = start_time self.schedule = schedule self.topic = topic -class RefreshDetails(msrest.serialization.Model): +class RefreshDetails(_serialization.Model): """Fields for tracking refresh job on the share. - :param in_progress_refresh_job_id: If a refresh share job is currently in progress on this + :ivar in_progress_refresh_job_id: If a refresh share job is currently in progress on this share, this field indicates the ARM resource ID of that job. The field is empty if no job is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share, if any.This could be a failed job or a successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh + :vartype in_progress_refresh_job_id: str + :ivar last_completed_refresh_job_time_in_utc: Indicates the completed time for the last refresh + job on this particular share, if any.This could be a failed job or a successful job. + :vartype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :ivar error_manifest_file: Indicates the relative path of the error xml for the last refresh job on this particular share, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share,if any. This + :vartype error_manifest_file: str + :ivar last_job: Indicates the id of the last refresh job on this particular share,if any. This could be a failed job or a successful job. - :type last_job: str + :vartype last_job: str """ _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, + "in_progress_refresh_job_id": {"key": "inProgressRefreshJobId", "type": "str"}, + "last_completed_refresh_job_time_in_utc": {"key": "lastCompletedRefreshJobTimeInUTC", "type": "iso-8601"}, + "error_manifest_file": {"key": "errorManifestFile", "type": "str"}, + "last_job": {"key": "lastJob", "type": "str"}, } def __init__( @@ -2116,14 +2289,29 @@ def __init__( last_job: Optional[str] = None, **kwargs ): - super(RefreshDetails, self).__init__(**kwargs) + """ + :keyword in_progress_refresh_job_id: If a refresh share job is currently in progress on this + share, this field indicates the ARM resource ID of that job. The field is empty if no job is in + progress. + :paramtype in_progress_refresh_job_id: str + :keyword last_completed_refresh_job_time_in_utc: Indicates the completed time for the last + refresh job on this particular share, if any.This could be a failed job or a successful job. + :paramtype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :keyword error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share, if any. This could be a failed job or a successful job. + :paramtype error_manifest_file: str + :keyword last_job: Indicates the id of the last refresh job on this particular share,if any. + This could be a failed job or a successful job. + :paramtype last_job: str + """ + super().__init__(**kwargs) self.in_progress_refresh_job_id = in_progress_refresh_job_id self.last_completed_refresh_job_time_in_utc = last_completed_refresh_job_time_in_utc self.error_manifest_file = error_manifest_file self.last_job = last_job -class RoleList(msrest.serialization.Model): +class RoleList(_serialization.Model): """Collection of all the roles on the Data Box Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2135,48 +2323,45 @@ class RoleList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Role]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RoleSinkInfo(msrest.serialization.Model): +class RoleSinkInfo(_serialization.Model): """Compute role against which events will be raised. All required parameters must be populated in order to send to Azure. - :param role_id: Required. Compute role ID. - :type role_id: str + :ivar role_id: Compute role ID. Required. + :vartype role_id: str """ _validation = { - 'role_id': {'required': True}, + "role_id": {"required": True}, } _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, + "role_id": {"key": "roleId", "type": "str"}, } - def __init__( - self, - *, - role_id: str, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) + def __init__(self, *, role_id: str, **kwargs): + """ + :keyword role_id: Compute role ID. Required. + :paramtype role_id: str + """ + super().__init__(**kwargs) self.role_id = role_id @@ -2193,61 +2378,64 @@ class SecuritySettings(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: + :ivar device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :vartype device_admin_password: ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "device_admin_password": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_admin_password": {"key": "properties.deviceAdminPassword", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - device_admin_password: "AsymmetricEncryptedSecret", - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) + def __init__(self, *, device_admin_password: "_models.AsymmetricEncryptedSecret", **kwargs): + """ + :keyword device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :paramtype device_admin_password: + ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.device_admin_password = device_admin_password -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification. - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: + :ivar metric_specifications: Metric specification as defined by shoebox. + :vartype metric_specifications: list[~azure.mgmt.databoxedge.v2019_07_01.models.MetricSpecificationV1] """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecificationV1]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["MetricSpecificationV1"]] = None, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecificationV1"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specification as defined by shoebox. + :paramtype metric_specifications: + list[~azure.mgmt.databoxedge.v2019_07_01.models.MetricSpecificationV1] + """ + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Share(ARMBaseModel): +class Share(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Represents a share on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2260,74 +2448,103 @@ class Share(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2019_07_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share + :ivar description: Description for the share. + :vartype description: str + :ivar share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :vartype share_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareStatus + :ivar monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :vartype monitoring_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.MonitoringStatus + :ivar azure_container_info: Azure container mapping for the share. + :vartype azure_container_info: ~azure.mgmt.databoxedge.v2019_07_01.models.AzureContainerInfo + :ivar access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :vartype access_protocol: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessProtocol + :ivar user_access_rights: Mapping of users and corresponding access rights on the share (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2019_07_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the + :vartype user_access_rights: list[~azure.mgmt.databoxedge.v2019_07_01.models.UserAccessRight] + :ivar client_access_rights: List of IP addresses and corresponding access rights on the share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2019_07_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2019_07_01.models.RefreshDetails + :vartype client_access_rights: + list[~azure.mgmt.databoxedge.v2019_07_01.models.ClientAccessRight] + :ivar refresh_details: Details of the refresh job on this share. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2019_07_01.models.RefreshDetails :ivar share_mappings: Share mount point to the role. :vartype share_mappings: list[~azure.mgmt.databoxedge.v2019_07_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2019_07_01.models.DataPolicy + :ivar data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2019_07_01.models.DataPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "share_status": {"required": True}, + "monitoring_status": {"required": True}, + "access_protocol": {"required": True}, + "share_mappings": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "share_status": {"key": "properties.shareStatus", "type": "str"}, + "monitoring_status": {"key": "properties.monitoringStatus", "type": "str"}, + "azure_container_info": {"key": "properties.azureContainerInfo", "type": "AzureContainerInfo"}, + "access_protocol": {"key": "properties.accessProtocol", "type": "str"}, + "user_access_rights": {"key": "properties.userAccessRights", "type": "[UserAccessRight]"}, + "client_access_rights": {"key": "properties.clientAccessRights", "type": "[ClientAccessRight]"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, } def __init__( self, *, - share_status: Union[str, "ShareStatus"], - monitoring_status: Union[str, "MonitoringStatus"], - access_protocol: Union[str, "ShareAccessProtocol"], + share_status: Union[str, "_models.ShareStatus"], + monitoring_status: Union[str, "_models.MonitoringStatus"], + access_protocol: Union[str, "_models.ShareAccessProtocol"], description: Optional[str] = None, - azure_container_info: Optional["AzureContainerInfo"] = None, - user_access_rights: Optional[List["UserAccessRight"]] = None, - client_access_rights: Optional[List["ClientAccessRight"]] = None, - refresh_details: Optional["RefreshDetails"] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, - **kwargs - ): - super(Share, self).__init__(**kwargs) + azure_container_info: Optional["_models.AzureContainerInfo"] = None, + user_access_rights: Optional[List["_models.UserAccessRight"]] = None, + client_access_rights: Optional[List["_models.ClientAccessRight"]] = None, + refresh_details: Optional["_models.RefreshDetails"] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, + **kwargs + ): + """ + :keyword description: Description for the share. + :paramtype description: str + :keyword share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :paramtype share_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareStatus + :keyword monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :paramtype monitoring_status: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.MonitoringStatus + :keyword azure_container_info: Azure container mapping for the share. + :paramtype azure_container_info: ~azure.mgmt.databoxedge.v2019_07_01.models.AzureContainerInfo + :keyword access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :paramtype access_protocol: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessProtocol + :keyword user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :paramtype user_access_rights: list[~azure.mgmt.databoxedge.v2019_07_01.models.UserAccessRight] + :keyword client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :paramtype client_access_rights: + list[~azure.mgmt.databoxedge.v2019_07_01.models.ClientAccessRight] + :keyword refresh_details: Details of the refresh job on this share. + :paramtype refresh_details: ~azure.mgmt.databoxedge.v2019_07_01.models.RefreshDetails + :keyword data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2019_07_01.models.DataPolicy + """ + super().__init__(**kwargs) self.description = description self.share_status = share_status self.monitoring_status = monitoring_status @@ -2340,41 +2557,42 @@ def __init__( self.data_policy = data_policy -class ShareAccessRight(msrest.serialization.Model): +class ShareAccessRight(_serialization.Model): """Specifies the mapping between this particular user and the type of access he has on shares on this device. All required parameters must be populated in order to send to Azure. - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessType + :ivar share_id: The share ID. Required. + :vartype share_id: str + :ivar access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessType """ _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, + "share_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) + def __init__(self, *, share_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword share_id: The share ID. Required. + :paramtype share_id: str + :keyword access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.share_id = share_id self.access_type = access_type -class ShareList(msrest.serialization.Model): +class ShareList(_serialization.Model): """Collection of all the shares on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2386,51 +2604,55 @@ class ShareList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Share]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU type. - :param name: SKU name. Possible values include: "Gateway", "Edge". - :type name: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SkuTier + :ivar name: SKU name. Known values are: "Gateway" and "Edge". + :vartype name: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SkuTier """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "SkuName"]] = None, - tier: Optional[Union[str, "SkuTier"]] = None, + name: Optional[Union[str, "_models.SkuName"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, **kwargs ): - super(Sku, self).__init__(**kwargs) + """ + :keyword name: SKU name. Known values are: "Gateway" and "Edge". + :paramtype name: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SkuName + :keyword tier: The SKU tier. This is based on the SKU name. "Standard" + :paramtype tier: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SkuTier + """ + super().__init__(**kwargs) self.name = name self.tier = tier -class StorageAccountCredential(ARMBaseModel): +class StorageAccountCredential(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The storage account credential. Variables are only populated by the server, and will be ignored when sending a request. @@ -2443,64 +2665,85 @@ class StorageAccountCredential(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str + :ivar alias: Alias for the storage account. Required. + :vartype alias: str + :ivar user_name: Username for the storage account. + :vartype user_name: str + :ivar account_key: Encrypted storage key. + :vartype account_key: ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string for the storage account. Use this string if username + and account key are not specified. + :vartype connection_string: str + :ivar ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values are: + "Enabled" and "Disabled". + :vartype ssl_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SSLStatus + :ivar blob_domain_name: Blob end point for private clouds. + :vartype blob_domain_name: str + :ivar account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :vartype account_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AccountType + :ivar storage_account_id: Id of the storage account. + :vartype storage_account_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "alias": {"required": True}, + "ssl_status": {"required": True}, + "account_type": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "alias": {"key": "properties.alias", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "account_key": {"key": "properties.accountKey", "type": "AsymmetricEncryptedSecret"}, + "connection_string": {"key": "properties.connectionString", "type": "str"}, + "ssl_status": {"key": "properties.sslStatus", "type": "str"}, + "blob_domain_name": {"key": "properties.blobDomainName", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, } def __init__( self, *, alias: str, - ssl_status: Union[str, "SSLStatus"], - account_type: Union[str, "AccountType"], + ssl_status: Union[str, "_models.SSLStatus"], + account_type: Union[str, "_models.AccountType"], user_name: Optional[str] = None, - account_key: Optional["AsymmetricEncryptedSecret"] = None, + account_key: Optional["_models.AsymmetricEncryptedSecret"] = None, connection_string: Optional[str] = None, blob_domain_name: Optional[str] = None, storage_account_id: Optional[str] = None, **kwargs ): - super(StorageAccountCredential, self).__init__(**kwargs) + """ + :keyword alias: Alias for the storage account. Required. + :paramtype alias: str + :keyword user_name: Username for the storage account. + :paramtype user_name: str + :keyword account_key: Encrypted storage key. + :paramtype account_key: ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret + :keyword connection_string: Connection string for the storage account. Use this string if + username and account key are not specified. + :paramtype connection_string: str + :keyword ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values + are: "Enabled" and "Disabled". + :paramtype ssl_status: str or ~azure.mgmt.databoxedge.v2019_07_01.models.SSLStatus + :keyword blob_domain_name: Blob end point for private clouds. + :paramtype blob_domain_name: str + :keyword account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :paramtype account_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AccountType + :keyword storage_account_id: Id of the storage account. + :paramtype storage_account_id: str + """ + super().__init__(**kwargs) self.alias = alias self.user_name = user_name self.account_key = account_key @@ -2511,7 +2754,7 @@ def __init__( self.storage_account_id = storage_account_id -class StorageAccountCredentialList(msrest.serialization.Model): +class StorageAccountCredentialList(_serialization.Model): """The collection of storage account credentials. Variables are only populated by the server, and will be ignored when sending a request. @@ -2523,63 +2766,62 @@ class StorageAccountCredentialList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccountCredential]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SymmetricKey(msrest.serialization.Model): +class SymmetricKey(_serialization.Model): """Symmetric key for authentication. - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string based on the symmetric key. + :vartype connection_string: + ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret """ _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, + "connection_string": {"key": "connectionString", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) + def __init__(self, *, connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs): + """ + :keyword connection_string: Connection string based on the symmetric key. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.connection_string = connection_string -class TrackingInfo(msrest.serialization.Model): +class TrackingInfo(_serialization.Model): """Tracking courier information. - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str + :ivar serial_number: Serial number of the device being tracked. + :vartype serial_number: str + :ivar carrier_name: Name of the carrier used in the delivery. + :vartype carrier_name: str + :ivar tracking_id: Tracking ID of the shipment. + :vartype tracking_id: str + :ivar tracking_url: Tracking URL of the shipment. + :vartype tracking_url: str """ _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, + "serial_number": {"key": "serialNumber", "type": "str"}, + "carrier_name": {"key": "carrierName", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "tracking_url": {"key": "trackingUrl", "type": "str"}, } def __init__( @@ -2591,14 +2833,24 @@ def __init__( tracking_url: Optional[str] = None, **kwargs ): - super(TrackingInfo, self).__init__(**kwargs) + """ + :keyword serial_number: Serial number of the device being tracked. + :paramtype serial_number: str + :keyword carrier_name: Name of the carrier used in the delivery. + :paramtype carrier_name: str + :keyword tracking_id: Tracking ID of the shipment. + :paramtype tracking_id: str + :keyword tracking_url: Tracking URL of the shipment. + :paramtype tracking_url: str + """ + super().__init__(**kwargs) self.serial_number = serial_number self.carrier_name = carrier_name self.tracking_id = tracking_id self.tracking_url = tracking_url -class TriggerList(msrest.serialization.Model): +class TriggerList(_serialization.Model): """Collection of all trigger on the data box edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2610,31 +2862,29 @@ class TriggerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Trigger]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class UpdateDownloadProgress(msrest.serialization.Model): +class UpdateDownloadProgress(_serialization.Model): """Details about the download progress of update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". + :ivar download_phase: The download phase. Known values are: "Unknown", "Initializing", + "Downloading", and "Verifying". :vartype download_phase: str or ~azure.mgmt.databoxedge.v2019_07_01.models.DownloadPhase :ivar percent_complete: Percentage of completion. :vartype percent_complete: int @@ -2649,28 +2899,26 @@ class UpdateDownloadProgress(msrest.serialization.Model): """ _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, + "download_phase": {"readonly": True}, + "percent_complete": {"readonly": True}, + "total_bytes_to_download": {"readonly": True}, + "total_bytes_downloaded": {"readonly": True}, + "number_of_updates_to_download": {"readonly": True}, + "number_of_updates_downloaded": {"readonly": True}, } _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, + "download_phase": {"key": "downloadPhase", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "total_bytes_to_download": {"key": "totalBytesToDownload", "type": "float"}, + "total_bytes_downloaded": {"key": "totalBytesDownloaded", "type": "float"}, + "number_of_updates_to_download": {"key": "numberOfUpdatesToDownload", "type": "int"}, + "number_of_updates_downloaded": {"key": "numberOfUpdatesDownloaded", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.download_phase = None self.percent_complete = None self.total_bytes_to_download = None @@ -2679,7 +2927,7 @@ def __init__( self.number_of_updates_downloaded = None -class UpdateInstallProgress(msrest.serialization.Model): +class UpdateInstallProgress(_serialization.Model): """Progress details during installation of updates. Variables are only populated by the server, and will be ignored when sending a request. @@ -2693,28 +2941,26 @@ class UpdateInstallProgress(msrest.serialization.Model): """ _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, + "percent_complete": {"readonly": True}, + "number_of_updates_to_install": {"readonly": True}, + "number_of_updates_installed": {"readonly": True}, } _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "number_of_updates_to_install": {"key": "numberOfUpdatesToInstall", "type": "int"}, + "number_of_updates_installed": {"key": "numberOfUpdatesInstalled", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.percent_complete = None self.number_of_updates_to_install = None self.number_of_updates_installed = None -class UpdateSummary(ARMBaseModel): +class UpdateSummary(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Details about ongoing updates and availability of updates on the device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2725,15 +2971,15 @@ class UpdateSummary(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed + :ivar device_version_number: The current version of the device in format: 1.2.17312.13.",. + :vartype device_version_number: str + :ivar friendly_device_version_name: The current version of the device in text format. + :vartype friendly_device_version_name: str + :ivar device_last_scanned_date_time: The last time when a scan was done on the device. + :vartype device_last_scanned_date_time: ~datetime.datetime + :ivar last_completed_scan_job_date_time: The time when the last scan job was completed (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime + :vartype last_completed_scan_job_date_time: ~datetime.datetime :ivar last_completed_download_job_date_time: The time when the last Download job was completed (success/cancelled/failed) on the appliance. :vartype last_completed_download_job_date_time: ~datetime.datetime @@ -2748,11 +2994,11 @@ class UpdateSummary(ARMBaseModel): :ivar total_number_of_updates_pending_install: The total number of items pending install. :vartype total_number_of_updates_pending_install: int :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.databoxedge.v2019_07_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". + :ivar ongoing_update_operation: The current update operation. Known values are: "None", "Scan", + "Download", and "Install". :vartype ongoing_update_operation: str or ~azure.mgmt.databoxedge.v2019_07_01.models.UpdateOperation :ivar in_progress_download_job_id: The job ID of the download job in progress. @@ -2772,45 +3018,63 @@ class UpdateSummary(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_completed_download_job_date_time": {"readonly": True}, + "last_completed_install_job_date_time": {"readonly": True}, + "total_number_of_updates_available": {"readonly": True}, + "total_number_of_updates_pending_download": {"readonly": True}, + "total_number_of_updates_pending_install": {"readonly": True}, + "reboot_behavior": {"readonly": True}, + "ongoing_update_operation": {"readonly": True}, + "in_progress_download_job_id": {"readonly": True}, + "in_progress_install_job_id": {"readonly": True}, + "in_progress_download_job_started_date_time": {"readonly": True}, + "in_progress_install_job_started_date_time": {"readonly": True}, + "update_titles": {"readonly": True}, + "total_update_size_in_bytes": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_version_number": {"key": "properties.deviceVersionNumber", "type": "str"}, + "friendly_device_version_name": {"key": "properties.friendlyDeviceVersionName", "type": "str"}, + "device_last_scanned_date_time": {"key": "properties.deviceLastScannedDateTime", "type": "iso-8601"}, + "last_completed_scan_job_date_time": {"key": "properties.lastCompletedScanJobDateTime", "type": "iso-8601"}, + "last_completed_download_job_date_time": { + "key": "properties.lastCompletedDownloadJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_date_time": { + "key": "properties.lastCompletedInstallJobDateTime", + "type": "iso-8601", + }, + "total_number_of_updates_available": {"key": "properties.totalNumberOfUpdatesAvailable", "type": "int"}, + "total_number_of_updates_pending_download": { + "key": "properties.totalNumberOfUpdatesPendingDownload", + "type": "int", + }, + "total_number_of_updates_pending_install": { + "key": "properties.totalNumberOfUpdatesPendingInstall", + "type": "int", + }, + "reboot_behavior": {"key": "properties.rebootBehavior", "type": "str"}, + "ongoing_update_operation": {"key": "properties.ongoingUpdateOperation", "type": "str"}, + "in_progress_download_job_id": {"key": "properties.inProgressDownloadJobId", "type": "str"}, + "in_progress_install_job_id": {"key": "properties.inProgressInstallJobId", "type": "str"}, + "in_progress_download_job_started_date_time": { + "key": "properties.inProgressDownloadJobStartedDateTime", + "type": "iso-8601", + }, + "in_progress_install_job_started_date_time": { + "key": "properties.inProgressInstallJobStartedDateTime", + "type": "iso-8601", + }, + "update_titles": {"key": "properties.updateTitles", "type": "[str]"}, + "total_update_size_in_bytes": {"key": "properties.totalUpdateSizeInBytes", "type": "float"}, } def __init__( @@ -2822,7 +3086,18 @@ def __init__( last_completed_scan_job_date_time: Optional[datetime.datetime] = None, **kwargs ): - super(UpdateSummary, self).__init__(**kwargs) + """ + :keyword device_version_number: The current version of the device in format: 1.2.17312.13.",. + :paramtype device_version_number: str + :keyword friendly_device_version_name: The current version of the device in text format. + :paramtype friendly_device_version_name: str + :keyword device_last_scanned_date_time: The last time when a scan was done on the device. + :paramtype device_last_scanned_date_time: ~datetime.datetime + :keyword last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :paramtype last_completed_scan_job_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.device_version_number = device_version_number self.friendly_device_version_name = friendly_device_version_name self.device_last_scanned_date_time = device_last_scanned_date_time @@ -2842,80 +3117,89 @@ def __init__( self.total_update_size_in_bytes = None -class UploadCertificateRequest(msrest.serialization.Model): +class UploadCertificateRequest(_serialization.Model): """The upload certificate request. All required parameters must be populated in order to send to Azure. - :param authentication_type: The authentication type. Possible values include: "Invalid", + :ivar authentication_type: The authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str + :vartype authentication_type: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.AuthenticationType + :ivar certificate: The base64 encoded certificate raw data. Required. + :vartype certificate: str """ _validation = { - 'certificate': {'required': True}, + "certificate": {"required": True}, } _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "certificate": {"key": "properties.certificate", "type": "str"}, } def __init__( self, *, certificate: str, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + **kwargs + ): + """ + :keyword authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype authentication_type: str or + ~azure.mgmt.databoxedge.v2019_07_01.models.AuthenticationType + :keyword certificate: The base64 encoded certificate raw data. Required. + :paramtype certificate: str + """ + super().__init__(**kwargs) self.authentication_type = authentication_type self.certificate = certificate -class UploadCertificateResponse(msrest.serialization.Model): +class UploadCertificateResponse(_serialization.Model): """The upload registration certificate response. All required parameters must be populated in order to send to Azure. - :param auth_type: Specifies authentication type. Possible values include: "Invalid", + :ivar auth_type: Specifies authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AuthenticationType - :param resource_id: Required. The resource ID of the Data Box Edge/Gateway device. - :type resource_id: str - :param aad_authority: Required. Azure Active Directory tenant authority. - :type aad_authority: str - :param aad_tenant_id: Required. Azure Active Directory tenant ID. - :type aad_tenant_id: str - :param service_principal_client_id: Required. Azure Active Directory service principal client - ID. - :type service_principal_client_id: str - :param service_principal_object_id: Required. Azure Active Directory service principal object - ID. - :type service_principal_object_id: str - :param azure_management_endpoint_audience: Required. The azure management endpoint audience. - :type azure_management_endpoint_audience: str + :vartype auth_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AuthenticationType + :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. Required. + :vartype resource_id: str + :ivar aad_authority: Azure Active Directory tenant authority. Required. + :vartype aad_authority: str + :ivar aad_tenant_id: Azure Active Directory tenant ID. Required. + :vartype aad_tenant_id: str + :ivar service_principal_client_id: Azure Active Directory service principal client ID. + Required. + :vartype service_principal_client_id: str + :ivar service_principal_object_id: Azure Active Directory service principal object ID. + Required. + :vartype service_principal_object_id: str + :ivar azure_management_endpoint_audience: The azure management endpoint audience. Required. + :vartype azure_management_endpoint_audience: str """ _validation = { - 'resource_id': {'required': True}, - 'aad_authority': {'required': True}, - 'aad_tenant_id': {'required': True}, - 'service_principal_client_id': {'required': True}, - 'service_principal_object_id': {'required': True}, - 'azure_management_endpoint_audience': {'required': True}, + "resource_id": {"required": True}, + "aad_authority": {"required": True}, + "aad_tenant_id": {"required": True}, + "service_principal_client_id": {"required": True}, + "service_principal_object_id": {"required": True}, + "azure_management_endpoint_audience": {"required": True}, } _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, + "auth_type": {"key": "authType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "aad_authority": {"key": "aadAuthority", "type": "str"}, + "aad_tenant_id": {"key": "aadTenantId", "type": "str"}, + "service_principal_client_id": {"key": "servicePrincipalClientId", "type": "str"}, + "service_principal_object_id": {"key": "servicePrincipalObjectId", "type": "str"}, + "azure_management_endpoint_audience": {"key": "azureManagementEndpointAudience", "type": "str"}, } def __init__( @@ -2927,10 +3211,29 @@ def __init__( service_principal_client_id: str, service_principal_object_id: str, azure_management_endpoint_audience: str, - auth_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) + auth_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + **kwargs + ): + """ + :keyword auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype auth_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.AuthenticationType + :keyword resource_id: The resource ID of the Data Box Edge/Gateway device. Required. + :paramtype resource_id: str + :keyword aad_authority: Azure Active Directory tenant authority. Required. + :paramtype aad_authority: str + :keyword aad_tenant_id: Azure Active Directory tenant ID. Required. + :paramtype aad_tenant_id: str + :keyword service_principal_client_id: Azure Active Directory service principal client ID. + Required. + :paramtype service_principal_client_id: str + :keyword service_principal_object_id: Azure Active Directory service principal object ID. + Required. + :paramtype service_principal_object_id: str + :keyword azure_management_endpoint_audience: The azure management endpoint audience. Required. + :paramtype azure_management_endpoint_audience: str + """ + super().__init__(**kwargs) self.auth_type = auth_type self.resource_id = resource_id self.aad_authority = aad_authority @@ -2951,74 +3254,85 @@ class User(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret - :param share_access_rights: List of shares that the user has rights on. This field should not - be specified during user creation. - :type share_access_rights: list[~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessRight] + :ivar encrypted_password: The password details. + :vartype encrypted_password: + ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret + :ivar share_access_rights: List of shares that the user has rights on. This field should not be + specified during user creation. + :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessRight] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encrypted_password": {"key": "properties.encryptedPassword", "type": "AsymmetricEncryptedSecret"}, + "share_access_rights": {"key": "properties.shareAccessRights", "type": "[ShareAccessRight]"}, } def __init__( self, *, - encrypted_password: Optional["AsymmetricEncryptedSecret"] = None, - share_access_rights: Optional[List["ShareAccessRight"]] = None, - **kwargs - ): - super(User, self).__init__(**kwargs) + encrypted_password: Optional["_models.AsymmetricEncryptedSecret"] = None, + share_access_rights: Optional[List["_models.ShareAccessRight"]] = None, + **kwargs + ): + """ + :keyword encrypted_password: The password details. + :paramtype encrypted_password: + ~azure.mgmt.databoxedge.v2019_07_01.models.AsymmetricEncryptedSecret + :keyword share_access_rights: List of shares that the user has rights on. This field should not + be specified during user creation. + :paramtype share_access_rights: + list[~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessRight] + """ + super().__init__(**kwargs) self.encrypted_password = encrypted_password self.share_access_rights = share_access_rights -class UserAccessRight(msrest.serialization.Model): +class UserAccessRight(_serialization.Model): """The mapping between a particular user and the access type on the SMB share. All required parameters must be populated in order to send to Azure. - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessType + :ivar user_id: User ID (already existing in the device). Required. + :vartype user_id: str + :ivar access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessType """ _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, + "user_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, + "user_id": {"key": "userId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, } - def __init__( - self, - *, - user_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) + def __init__(self, *, user_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword user_id: User ID (already existing in the device). Required. + :paramtype user_id: str + :keyword access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2019_07_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.user_id = user_id self.access_type = access_type -class UserList(msrest.serialization.Model): +class UserList(_serialization.Model): """Collection of users. Variables are only populated by the server, and will be ignored when sending a request. @@ -3030,19 +3344,17 @@ class UserList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[User]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/__init__.py index 6d25b62f30f7..b9103503dff3 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/__init__.py @@ -20,18 +20,24 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_alerts_operations.py index a9186ae3352d..f9c5b259958e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class AlertsOperations(object): - """AlertsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_by_data_box_edge_device_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,72 +206,73 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_bandwidth_schedules_operations.py index 2d59ed718fa0..b32ec0196fec 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,268 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class BandwidthSchedulesOperations(object): - """BandwidthSchedulesOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BandwidthSchedulesList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +276,126 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BandwidthSchedule" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BandwidthSchedule"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +404,215 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BandwidthSchedule"] + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +622,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_devices_operations.py index e1c98ec9a63f..91e6f1a0e37d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,581 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", + ) # 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"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_download_updates_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_extended_information_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_install_updates_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_settings_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_scan_for_updates_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_security_settings_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class DevicesOperations(object): - """DevicesOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_update_summary_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_upload_certificate_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_subscription( - self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,75 +589,90 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + @distributed_trace def list_by_resource_group( - self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,230 +681,325 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } def _create_or_update_initial( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -425,174 +1009,243 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def update( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDevicePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - def _download_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -602,168 +1255,170 @@ def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } - def begin_download_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_download_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._download_updates_initial( + raw_result = self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace def get_extended_information( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - def _install_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -773,168 +1428,170 @@ def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } - def begin_install_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_install_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._install_updates_initial( + raw_result = self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace def get_network_settings( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkSettings" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - def _scan_for_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -944,115 +1601,124 @@ def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def begin_scan_for_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_scan_for_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._scan_for_updates_initial( + raw_result = self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def _create_or_update_security_settings_initial( + def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1062,202 +1728,353 @@ def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload def begin_create_or_update_security_settings( self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2019_07_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2019_07_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_security_settings_initial( + raw_result = self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def get_update_summary( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateSummary" - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @distributed_trace + def get_update_summary(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload def upload_certificate( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.UploadCertificateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.UploadCertificateResponse" + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_jobs_operations.py index 561dd867f1e6..d7cb90ad1eea 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class JobsOperations(object): - """JobsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_nodes_operations.py index d27783f71dc1..67dbc6a72d6b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,166 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class NodesOperations(object): - """NodesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NodeList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +174,8 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_operations.py index 175e9a141ede..2c6194dd63a1 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") -class Operations(object): - """Operations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataBoxEdge/operations") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +155,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_operations_status_operations.py index e67f78f60dad..3d7e36ca1253 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class OperationsStatusOperations(object): - """OperationsStatusOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_orders_operations.py index fa7e56a2dcb7..f2d29cdcf8d8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,264 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request(device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class OrdersOperations(object): - """OrdersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OrderList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,112 +272,119 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Order" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } def _create_or_update_initial( - self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Order"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,122 +393,200 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Order"] + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2019_07_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2019_07_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,71 +596,71 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_roles_operations.py index 2c7f33f1d31e..3ec4ac58950e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,267 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class RolesOperations(object): - """RolesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +275,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Role" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Role"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +398,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Role"] + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2019_07_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2019_07_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +604,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_shares_operations.py index dc6a461b1808..1ede35687860 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,301 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_delete_request( + device_name: str, name: str, 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 {}) -class SharesOperations(object): - """SharesOperations operations. + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ShareList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +309,123 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Share" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Share"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +434,209 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Share"] + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2019_07_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2019_07_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,114 +646,110 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -488,76 +759,74 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } - def begin_refresh( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_refresh(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_storage_account_credentials_operations.py index 5f5eefec1248..4900e2d6fe88 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,271 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class StorageAccountCredentialsOperations(object): - """StorageAccountCredentialsOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountCredentialList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,116 +279,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountCredential" + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccountCredential"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -237,127 +409,217 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccountCredential"] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -367,74 +629,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_triggers_operations.py index 9c2ed94ccc52..3efb464dd3f8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,273 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class TriggersOperations(object): - """TriggersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TriggerList"] + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +281,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Trigger" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Trigger"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,127 +404,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Trigger"] + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2019_07_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Trigger or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2019_07_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +610,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_users_operations.py index 6eea2a22d3d6..327d7df59e68 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_07_01/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,267 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class UsersOperations(object): - """UsersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_07_01.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 UserList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_07_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +275,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_07_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.User"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,128 +398,206 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.User"] + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2019_07_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2019_07_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_07_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -366,74 +607,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/__init__.py index e63196b6b98f..d2bcf6a47896 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/__init__.py @@ -7,10 +7,20 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_configuration.py index 1e8ec7d68167..3499033d150c 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_configuration.py @@ -6,65 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", "2019-08-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-08-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_data_box_edge_management_client.py index 0af6918216f3..eb99927b3698 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_data_box_edge_management_client.py @@ -6,39 +6,40 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AlertsOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + SkusOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .operations import SkusOperations -from . import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations @@ -48,13 +49,15 @@ class DataBoxEdgeManagementClient(object): :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2019_08_01.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2019_08_01.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2019_08_01.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2019_08_01.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2019_08_01.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2019_08_01.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2019_08_01.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2019_08_01.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -62,9 +65,11 @@ class DataBoxEdgeManagementClient(object): :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2019_08_01.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2019_08_01.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2019_08_01.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2019_08_01.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2019_08_01.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations :vartype containers: azure.mgmt.databoxedge.v2019_08_01.operations.ContainersOperations :ivar triggers: TriggersOperations operations @@ -73,92 +78,88 @@ class DataBoxEdgeManagementClient(object): :vartype users: azure.mgmt.databoxedge.v2019_08_01.operations.UsersOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.databoxedge.v2019_08_01.operations.SkusOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-08-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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None + + 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) -> None: self._client.close() - def __enter__(self): - # type: () -> DataBoxEdgeManagementClient + def __enter__(self) -> "DataBoxEdgeManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_metadata.json b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_metadata.json index df175d3bbf33..9514a810bbf7 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_metadata.json +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_metadata.json @@ -5,25 +5,25 @@ "name": "DataBoxEdgeManagementClient", "filename": "_data_box_edge_management_client", "description": "The DataBoxEdge Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription ID.", + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription ID.", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=None, # type: Optional[str]", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -115,4 +114,4 @@ "users": "UsersOperations", "skus": "SkusOperations" } -} \ No newline at end of file +} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_vendor.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_version.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/__init__.py index c33d46ee91d8..fcb8775eaa10 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_configuration.py index 4b87b6133392..63ab5b2695d8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_configuration.py @@ -6,61 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-08-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", "2019-08-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-08-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_data_box_edge_management_client.py index 478a535da5e8..1b17e9eea1be 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_data_box_edge_management_client.py @@ -6,37 +6,40 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AlertsOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + SkusOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .operations import SkusOperations -from .. import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations @@ -46,13 +49,15 @@ class DataBoxEdgeManagementClient(object): :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2019_08_01.aio.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2019_08_01.aio.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2019_08_01.aio.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2019_08_01.aio.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2019_08_01.aio.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2019_08_01.aio.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2019_08_01.aio.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2019_08_01.aio.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -60,9 +65,11 @@ class DataBoxEdgeManagementClient(object): :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2019_08_01.aio.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2019_08_01.aio.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2019_08_01.aio.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2019_08_01.aio.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2019_08_01.aio.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations :vartype containers: azure.mgmt.databoxedge.v2019_08_01.aio.operations.ContainersOperations :ivar triggers: TriggersOperations operations @@ -71,80 +78,81 @@ class DataBoxEdgeManagementClient(object): :vartype users: azure.mgmt.databoxedge.v2019_08_01.aio.operations.UsersOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.databoxedge.v2019_08_01.aio.operations.SkusOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-08-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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/__init__.py index 3897ada67557..19bf7b429223 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/__init__.py @@ -23,21 +23,27 @@ from ._users_operations import UsersOperations from ._skus_operations import SkusOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', - 'SkusOperations', + "Operations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_alerts_operations.py index a2fb12fcaa76..d98d4d65ba91 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._alerts_operations import build_get_request, build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AlertsOperations: - """AlertsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AlertList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,71 +142,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Alert": + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_bandwidth_schedules_operations.py index ad93fee72241..dde0383eab2d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._bandwidth_schedules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BandwidthSchedulesOperations: - """BandwidthSchedulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.BandwidthSchedulesList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.BandwidthSchedule": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> Optional["_models.BandwidthSchedule"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +279,215 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> AsyncLROPoller["_models.BandwidthSchedule"]: + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +497,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_containers_operations.py index 1ed42763c01f..811f875f4640 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._containers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_storage_account_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainersOperations: - """ContainersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_storage_account( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ContainerList"]: + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,78 +155,81 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Container": + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } async def _create_or_update_initial( self, @@ -197,43 +237,53 @@ async def _create_or_update_initial( storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> Optional["_models.Container"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -242,54 +292,155 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> AsyncLROPoller["_models.Container"]: + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2019_08_01.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Container or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Container] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2019_08_01.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -297,79 +448,75 @@ async def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -379,119 +526,116 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -501,80 +645,79 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_devices_operations.py index 3bccba17df82..5082aa82e1ee 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._devices_operations import ( + build_create_or_update_request, + build_create_or_update_security_settings_request, + build_delete_request, + build_download_updates_request, + build_get_extended_information_request, + build_get_network_settings_request, + build_get_request, + build_get_update_summary_request, + build_install_updates_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_scan_for_updates_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations: - """DevicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_subscription( - self, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,74 +158,90 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,226 +250,325 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDevice": + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } async def _create_or_update_initial( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> "_models.DataBoxEdgeDevice": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> AsyncLROPoller["_models.DataBoxEdgeDevice"]: + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -415,171 +578,243 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload async def update( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDevicePatch", - **kwargs - ) -> "_models.DataBoxEdgeDevice": + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - async def _download_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -589,165 +824,172 @@ async def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def begin_download_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._download_updates_initial( + raw_result = await self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace_async async def get_extended_information( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - async def _install_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + async def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -757,165 +999,172 @@ async def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def begin_install_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._install_updates_initial( + raw_result = await self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def get_network_settings( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.NetworkSettings": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - async def _scan_for_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + async def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -925,113 +1174,126 @@ async def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + @distributed_trace_async async def begin_scan_for_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._scan_for_updates_initial( + raw_result = await self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _create_or_update_security_settings_initial( + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + + async def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1041,199 +1303,355 @@ async def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload async def begin_create_or_update_security_settings( self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2019_08_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2019_08_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_security_settings_initial( + raw_result = await self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @distributed_trace_async async def get_update_summary( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.UpdateSummary": - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload async def upload_certificate( self, device_name: str, resource_group_name: str, - parameters: "_models.UploadCertificateRequest", - **kwargs - ) -> "_models.UploadCertificateResponse": + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_jobs_operations.py index b03d8568a77a..c3aa0ee42905 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class JobsOperations: - """JobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_nodes_operations.py index d9d6afc3ee45..855b975ac36b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._nodes_operations import build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NodesOperations: - """NodesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.NodeList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +141,8 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_operations.py index 336edd0b9ab2..cb971267d45e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,126 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.OperationsList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +134,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_operations_status_operations.py index 62707ccfeba5..c768b8b95ee9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations_status_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsStatusOperations: - """OperationsStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_orders_operations.py index f4b7df965092..5cea8d1c96cb 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._orders_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OrdersOperations: - """OrdersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.OrderList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,110 +151,119 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Order": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } async def _create_or_update_initial( - self, - device_name: str, - resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> Optional["_models.Order"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -226,120 +272,200 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> AsyncLROPoller["_models.Order"]: + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2019_08_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2019_08_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -349,70 +475,71 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_roles_operations.py index 822acd6ddbe0..cedf1615bcd9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._roles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RolesOperations: - """RolesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.RoleList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Role": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> Optional["_models.Role"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +272,203 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> AsyncLROPoller["_models.Role"]: + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2019_08_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2019_08_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +478,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_shares_operations.py index 1546cffb958f..b460cb7e1099 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._shares_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SharesOperations: - """SharesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ShareList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +152,123 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Share": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> Optional["_models.Share"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +277,209 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> AsyncLROPoller["_models.Share"]: + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2019_08_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2019_08_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,112 +489,112 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -477,75 +604,76 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_skus_operations.py index 45fbdcb005d9..03c7f91a8f96 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.SkuInformationList"]: + 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 + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.ResourceTypeSku"]: """List all the available Skus in the region and information related to them. List all the available Skus in the region and information related to them. - :param filter: Specify $filter='location eq :code:``' to filter on location. + :param filter: Specify $filter='location eq :code:``' to filter on location. Default + value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkuInformationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.SkuInformationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceTypeSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.ResourceTypeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuInformationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.SkuInformationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SkuInformationList', pipeline_response) + deserialized = self._deserialize("SkuInformationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,7 +139,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_storage_account_credentials_operations.py index 1b7fc04d944c..6c8a8a16a017 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_account_credentials_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountCredentialsOperations: - """StorageAccountCredentialsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountCredentialList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,114 +152,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccountCredential": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> Optional["_models.StorageAccountCredential"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -230,125 +282,217 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccountCredential"]: + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,73 +502,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_storage_accounts_operations.py index 65fdbb465b3b..cfd1db1cda96 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_accounts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountsOperations: - """StorageAccountsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts in a Data Box Edge/Data Box Gateway device. Lists all the storage accounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +151,130 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccount": + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } async def _create_or_update_initial( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +283,221 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccount"]: + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -362,73 +507,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_triggers_operations.py index d066a5070140..04a8ebaeb51f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._triggers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TriggersOperations: - """TriggersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.TriggerList"]: + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +153,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Trigger": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> Optional["_models.Trigger"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,125 +276,206 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> AsyncLROPoller["_models.Trigger"]: + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2019_08_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Trigger or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Trigger or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2019_08_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +485,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_users_operations.py index 456ca3b771d3..3ea089200fcf 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/aio/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UsersOperations: - """UsersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.aio.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.UserList"]: + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='UserType eq :code:``' to filter on user type property. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,114 +153,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.User": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - user: "_models.User", - **kwargs - ) -> Optional["_models.User"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,126 +276,206 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - user: "_models.User", - **kwargs - ) -> AsyncLROPoller["_models.User"]: + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2019_08_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2019_08_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +485,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/__init__.py index bd24cea04afc..143de6c512c4 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/__init__.py @@ -6,321 +6,246 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARMBaseModel - from ._models_py3 import Address - from ._models_py3 import Alert - from ._models_py3 import AlertErrorDetails - from ._models_py3 import AlertList - from ._models_py3 import AsymmetricEncryptedSecret - from ._models_py3 import Authentication - from ._models_py3 import AzureContainerInfo - from ._models_py3 import BandwidthSchedule - from ._models_py3 import BandwidthSchedulesList - from ._models_py3 import ClientAccessRight - from ._models_py3 import CloudErrorBody - from ._models_py3 import ContactDetails - from ._models_py3 import Container - from ._models_py3 import ContainerList - from ._models_py3 import DataBoxEdgeDevice - from ._models_py3 import DataBoxEdgeDeviceExtendedInfo - from ._models_py3 import DataBoxEdgeDeviceList - from ._models_py3 import DataBoxEdgeDevicePatch - from ._models_py3 import FileEventTrigger - from ._models_py3 import FileSourceInfo - from ._models_py3 import IoTDeviceInfo - from ._models_py3 import IoTRole - from ._models_py3 import Ipv4Config - from ._models_py3 import Ipv6Config - from ._models_py3 import Job - from ._models_py3 import JobErrorDetails - from ._models_py3 import JobErrorItem - from ._models_py3 import MetricDimensionV1 - from ._models_py3 import MetricSpecificationV1 - from ._models_py3 import MountPointMap - from ._models_py3 import NetworkAdapter - from ._models_py3 import NetworkAdapterPosition - from ._models_py3 import NetworkSettings - from ._models_py3 import Node - from ._models_py3 import NodeList - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import Order - from ._models_py3 import OrderList - from ._models_py3 import OrderStatus - from ._models_py3 import PeriodicTimerEventTrigger - from ._models_py3 import PeriodicTimerSourceInfo - from ._models_py3 import RefreshDetails - from ._models_py3 import ResourceTypeSku - from ._models_py3 import Role - from ._models_py3 import RoleList - from ._models_py3 import RoleSinkInfo - from ._models_py3 import SecuritySettings - from ._models_py3 import ServiceSpecification - from ._models_py3 import Share - from ._models_py3 import ShareAccessRight - from ._models_py3 import ShareList - from ._models_py3 import Sku - from ._models_py3 import SkuCost - from ._models_py3 import SkuInformationList - from ._models_py3 import SkuLocationInfo - from ._models_py3 import SkuRestriction - from ._models_py3 import SkuRestrictionInfo - from ._models_py3 import StorageAccount - from ._models_py3 import StorageAccountCredential - from ._models_py3 import StorageAccountCredentialList - from ._models_py3 import StorageAccountList - from ._models_py3 import SymmetricKey - from ._models_py3 import TrackingInfo - from ._models_py3 import Trigger - from ._models_py3 import TriggerList - from ._models_py3 import UpdateDownloadProgress - from ._models_py3 import UpdateInstallProgress - from ._models_py3 import UpdateSummary - from ._models_py3 import UploadCertificateRequest - from ._models_py3 import UploadCertificateResponse - from ._models_py3 import User - from ._models_py3 import UserAccessRight - from ._models_py3 import UserList -except (SyntaxError, ImportError): - from ._models import ARMBaseModel # type: ignore - from ._models import Address # type: ignore - from ._models import Alert # type: ignore - from ._models import AlertErrorDetails # type: ignore - from ._models import AlertList # type: ignore - from ._models import AsymmetricEncryptedSecret # type: ignore - from ._models import Authentication # type: ignore - from ._models import AzureContainerInfo # type: ignore - from ._models import BandwidthSchedule # type: ignore - from ._models import BandwidthSchedulesList # type: ignore - from ._models import ClientAccessRight # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import ContactDetails # type: ignore - from ._models import Container # type: ignore - from ._models import ContainerList # type: ignore - from ._models import DataBoxEdgeDevice # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfo # type: ignore - from ._models import DataBoxEdgeDeviceList # type: ignore - from ._models import DataBoxEdgeDevicePatch # type: ignore - from ._models import FileEventTrigger # type: ignore - from ._models import FileSourceInfo # type: ignore - from ._models import IoTDeviceInfo # type: ignore - from ._models import IoTRole # type: ignore - from ._models import Ipv4Config # type: ignore - from ._models import Ipv6Config # type: ignore - from ._models import Job # type: ignore - from ._models import JobErrorDetails # type: ignore - from ._models import JobErrorItem # type: ignore - from ._models import MetricDimensionV1 # type: ignore - from ._models import MetricSpecificationV1 # type: ignore - from ._models import MountPointMap # type: ignore - from ._models import NetworkAdapter # type: ignore - from ._models import NetworkAdapterPosition # type: ignore - from ._models import NetworkSettings # type: ignore - from ._models import Node # type: ignore - from ._models import NodeList # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import Order # type: ignore - from ._models import OrderList # type: ignore - from ._models import OrderStatus # type: ignore - from ._models import PeriodicTimerEventTrigger # type: ignore - from ._models import PeriodicTimerSourceInfo # type: ignore - from ._models import RefreshDetails # type: ignore - from ._models import ResourceTypeSku # type: ignore - from ._models import Role # type: ignore - from ._models import RoleList # type: ignore - from ._models import RoleSinkInfo # type: ignore - from ._models import SecuritySettings # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Share # type: ignore - from ._models import ShareAccessRight # type: ignore - from ._models import ShareList # type: ignore - from ._models import Sku # type: ignore - from ._models import SkuCost # type: ignore - from ._models import SkuInformationList # type: ignore - from ._models import SkuLocationInfo # type: ignore - from ._models import SkuRestriction # type: ignore - from ._models import SkuRestrictionInfo # type: ignore - from ._models import StorageAccount # type: ignore - from ._models import StorageAccountCredential # type: ignore - from ._models import StorageAccountCredentialList # type: ignore - from ._models import StorageAccountList # type: ignore - from ._models import SymmetricKey # type: ignore - from ._models import TrackingInfo # type: ignore - from ._models import Trigger # type: ignore - from ._models import TriggerList # type: ignore - from ._models import UpdateDownloadProgress # type: ignore - from ._models import UpdateInstallProgress # type: ignore - from ._models import UpdateSummary # type: ignore - from ._models import UploadCertificateRequest # type: ignore - from ._models import UploadCertificateResponse # type: ignore - from ._models import User # type: ignore - from ._models import UserAccessRight # type: ignore - from ._models import UserList # type: ignore +from ._models_py3 import ARMBaseModel +from ._models_py3 import Address +from ._models_py3 import Alert +from ._models_py3 import AlertErrorDetails +from ._models_py3 import AlertList +from ._models_py3 import AsymmetricEncryptedSecret +from ._models_py3 import Authentication +from ._models_py3 import AzureContainerInfo +from ._models_py3 import BandwidthSchedule +from ._models_py3 import BandwidthSchedulesList +from ._models_py3 import ClientAccessRight +from ._models_py3 import CloudErrorBody +from ._models_py3 import ContactDetails +from ._models_py3 import Container +from ._models_py3 import ContainerList +from ._models_py3 import DataBoxEdgeDevice +from ._models_py3 import DataBoxEdgeDeviceExtendedInfo +from ._models_py3 import DataBoxEdgeDeviceList +from ._models_py3 import DataBoxEdgeDevicePatch +from ._models_py3 import FileEventTrigger +from ._models_py3 import FileSourceInfo +from ._models_py3 import IoTDeviceInfo +from ._models_py3 import IoTRole +from ._models_py3 import Ipv4Config +from ._models_py3 import Ipv6Config +from ._models_py3 import Job +from ._models_py3 import JobErrorDetails +from ._models_py3 import JobErrorItem +from ._models_py3 import MetricDimensionV1 +from ._models_py3 import MetricSpecificationV1 +from ._models_py3 import MountPointMap +from ._models_py3 import NetworkAdapter +from ._models_py3 import NetworkAdapterPosition +from ._models_py3 import NetworkSettings +from ._models_py3 import Node +from ._models_py3 import NodeList +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import Order +from ._models_py3 import OrderList +from ._models_py3 import OrderStatus +from ._models_py3 import PeriodicTimerEventTrigger +from ._models_py3 import PeriodicTimerSourceInfo +from ._models_py3 import RefreshDetails +from ._models_py3 import ResourceTypeSku +from ._models_py3 import Role +from ._models_py3 import RoleList +from ._models_py3 import RoleSinkInfo +from ._models_py3 import SecuritySettings +from ._models_py3 import ServiceSpecification +from ._models_py3 import Share +from ._models_py3 import ShareAccessRight +from ._models_py3 import ShareList +from ._models_py3 import Sku +from ._models_py3 import SkuCost +from ._models_py3 import SkuInformationList +from ._models_py3 import SkuLocationInfo +from ._models_py3 import SkuRestriction +from ._models_py3 import SkuRestrictionInfo +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCredential +from ._models_py3 import StorageAccountCredentialList +from ._models_py3 import StorageAccountList +from ._models_py3 import SymmetricKey +from ._models_py3 import TrackingInfo +from ._models_py3 import Trigger +from ._models_py3 import TriggerList +from ._models_py3 import UpdateDownloadProgress +from ._models_py3 import UpdateInstallProgress +from ._models_py3 import UpdateSummary +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UploadCertificateResponse +from ._models_py3 import User +from ._models_py3 import UserAccessRight +from ._models_py3 import UserList -from ._data_box_edge_management_client_enums import ( - AccountType, - AlertSeverity, - AuthenticationType, - AzureContainerDataFormat, - ClientPermissionType, - ContainerStatus, - DataBoxEdgeDeviceStatus, - DataPolicy, - DayOfWeek, - DeviceType, - DownloadPhase, - EncryptionAlgorithm, - InstallRebootBehavior, - JobStatus, - JobType, - MetricAggregationType, - MetricCategory, - MetricUnit, - MonitoringStatus, - NetworkAdapterDHCPStatus, - NetworkAdapterRDMAStatus, - NetworkAdapterStatus, - NetworkGroup, - NodeStatus, - OrderState, - PlatformType, - RoleStatus, - RoleTypes, - SSLStatus, - ShareAccessProtocol, - ShareAccessType, - ShareStatus, - SkuName, - SkuRestrictionReasonCode, - SkuTier, - StorageAccountStatus, - TimeGrain, - TriggerEventType, - UpdateOperation, - UpdateOperationStage, - UserType, -) +from ._data_box_edge_management_client_enums import AccountType +from ._data_box_edge_management_client_enums import AlertSeverity +from ._data_box_edge_management_client_enums import AuthenticationType +from ._data_box_edge_management_client_enums import AzureContainerDataFormat +from ._data_box_edge_management_client_enums import ClientPermissionType +from ._data_box_edge_management_client_enums import ContainerStatus +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceStatus +from ._data_box_edge_management_client_enums import DataPolicy +from ._data_box_edge_management_client_enums import DayOfWeek +from ._data_box_edge_management_client_enums import DeviceType +from ._data_box_edge_management_client_enums import DownloadPhase +from ._data_box_edge_management_client_enums import EncryptionAlgorithm +from ._data_box_edge_management_client_enums import InstallRebootBehavior +from ._data_box_edge_management_client_enums import JobStatus +from ._data_box_edge_management_client_enums import JobType +from ._data_box_edge_management_client_enums import MetricAggregationType +from ._data_box_edge_management_client_enums import MetricCategory +from ._data_box_edge_management_client_enums import MetricUnit +from ._data_box_edge_management_client_enums import MonitoringStatus +from ._data_box_edge_management_client_enums import NetworkAdapterDHCPStatus +from ._data_box_edge_management_client_enums import NetworkAdapterRDMAStatus +from ._data_box_edge_management_client_enums import NetworkAdapterStatus +from ._data_box_edge_management_client_enums import NetworkGroup +from ._data_box_edge_management_client_enums import NodeStatus +from ._data_box_edge_management_client_enums import OrderState +from ._data_box_edge_management_client_enums import PlatformType +from ._data_box_edge_management_client_enums import RoleStatus +from ._data_box_edge_management_client_enums import RoleTypes +from ._data_box_edge_management_client_enums import SSLStatus +from ._data_box_edge_management_client_enums import ShareAccessProtocol +from ._data_box_edge_management_client_enums import ShareAccessType +from ._data_box_edge_management_client_enums import ShareStatus +from ._data_box_edge_management_client_enums import SkuName +from ._data_box_edge_management_client_enums import SkuRestrictionReasonCode +from ._data_box_edge_management_client_enums import SkuTier +from ._data_box_edge_management_client_enums import StorageAccountStatus +from ._data_box_edge_management_client_enums import TimeGrain +from ._data_box_edge_management_client_enums import TriggerEventType +from ._data_box_edge_management_client_enums import UpdateOperation +from ._data_box_edge_management_client_enums import UpdateOperationStage +from ._data_box_edge_management_client_enums import UserType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ARMBaseModel', - 'Address', - 'Alert', - 'AlertErrorDetails', - 'AlertList', - 'AsymmetricEncryptedSecret', - 'Authentication', - 'AzureContainerInfo', - 'BandwidthSchedule', - 'BandwidthSchedulesList', - 'ClientAccessRight', - 'CloudErrorBody', - 'ContactDetails', - 'Container', - 'ContainerList', - 'DataBoxEdgeDevice', - 'DataBoxEdgeDeviceExtendedInfo', - 'DataBoxEdgeDeviceList', - 'DataBoxEdgeDevicePatch', - 'FileEventTrigger', - 'FileSourceInfo', - 'IoTDeviceInfo', - 'IoTRole', - 'Ipv4Config', - 'Ipv6Config', - 'Job', - 'JobErrorDetails', - 'JobErrorItem', - 'MetricDimensionV1', - 'MetricSpecificationV1', - 'MountPointMap', - 'NetworkAdapter', - 'NetworkAdapterPosition', - 'NetworkSettings', - 'Node', - 'NodeList', - 'Operation', - 'OperationDisplay', - 'OperationsList', - 'Order', - 'OrderList', - 'OrderStatus', - 'PeriodicTimerEventTrigger', - 'PeriodicTimerSourceInfo', - 'RefreshDetails', - 'ResourceTypeSku', - 'Role', - 'RoleList', - 'RoleSinkInfo', - 'SecuritySettings', - 'ServiceSpecification', - 'Share', - 'ShareAccessRight', - 'ShareList', - 'Sku', - 'SkuCost', - 'SkuInformationList', - 'SkuLocationInfo', - 'SkuRestriction', - 'SkuRestrictionInfo', - 'StorageAccount', - 'StorageAccountCredential', - 'StorageAccountCredentialList', - 'StorageAccountList', - 'SymmetricKey', - 'TrackingInfo', - 'Trigger', - 'TriggerList', - 'UpdateDownloadProgress', - 'UpdateInstallProgress', - 'UpdateSummary', - 'UploadCertificateRequest', - 'UploadCertificateResponse', - 'User', - 'UserAccessRight', - 'UserList', - 'AccountType', - 'AlertSeverity', - 'AuthenticationType', - 'AzureContainerDataFormat', - 'ClientPermissionType', - 'ContainerStatus', - 'DataBoxEdgeDeviceStatus', - 'DataPolicy', - 'DayOfWeek', - 'DeviceType', - 'DownloadPhase', - 'EncryptionAlgorithm', - 'InstallRebootBehavior', - 'JobStatus', - 'JobType', - 'MetricAggregationType', - 'MetricCategory', - 'MetricUnit', - 'MonitoringStatus', - 'NetworkAdapterDHCPStatus', - 'NetworkAdapterRDMAStatus', - 'NetworkAdapterStatus', - 'NetworkGroup', - 'NodeStatus', - 'OrderState', - 'PlatformType', - 'RoleStatus', - 'RoleTypes', - 'SSLStatus', - 'ShareAccessProtocol', - 'ShareAccessType', - 'ShareStatus', - 'SkuName', - 'SkuRestrictionReasonCode', - 'SkuTier', - 'StorageAccountStatus', - 'TimeGrain', - 'TriggerEventType', - 'UpdateOperation', - 'UpdateOperationStage', - 'UserType', + "ARMBaseModel", + "Address", + "Alert", + "AlertErrorDetails", + "AlertList", + "AsymmetricEncryptedSecret", + "Authentication", + "AzureContainerInfo", + "BandwidthSchedule", + "BandwidthSchedulesList", + "ClientAccessRight", + "CloudErrorBody", + "ContactDetails", + "Container", + "ContainerList", + "DataBoxEdgeDevice", + "DataBoxEdgeDeviceExtendedInfo", + "DataBoxEdgeDeviceList", + "DataBoxEdgeDevicePatch", + "FileEventTrigger", + "FileSourceInfo", + "IoTDeviceInfo", + "IoTRole", + "Ipv4Config", + "Ipv6Config", + "Job", + "JobErrorDetails", + "JobErrorItem", + "MetricDimensionV1", + "MetricSpecificationV1", + "MountPointMap", + "NetworkAdapter", + "NetworkAdapterPosition", + "NetworkSettings", + "Node", + "NodeList", + "Operation", + "OperationDisplay", + "OperationsList", + "Order", + "OrderList", + "OrderStatus", + "PeriodicTimerEventTrigger", + "PeriodicTimerSourceInfo", + "RefreshDetails", + "ResourceTypeSku", + "Role", + "RoleList", + "RoleSinkInfo", + "SecuritySettings", + "ServiceSpecification", + "Share", + "ShareAccessRight", + "ShareList", + "Sku", + "SkuCost", + "SkuInformationList", + "SkuLocationInfo", + "SkuRestriction", + "SkuRestrictionInfo", + "StorageAccount", + "StorageAccountCredential", + "StorageAccountCredentialList", + "StorageAccountList", + "SymmetricKey", + "TrackingInfo", + "Trigger", + "TriggerList", + "UpdateDownloadProgress", + "UpdateInstallProgress", + "UpdateSummary", + "UploadCertificateRequest", + "UploadCertificateResponse", + "User", + "UserAccessRight", + "UserList", + "AccountType", + "AlertSeverity", + "AuthenticationType", + "AzureContainerDataFormat", + "ClientPermissionType", + "ContainerStatus", + "DataBoxEdgeDeviceStatus", + "DataPolicy", + "DayOfWeek", + "DeviceType", + "DownloadPhase", + "EncryptionAlgorithm", + "InstallRebootBehavior", + "JobStatus", + "JobType", + "MetricAggregationType", + "MetricCategory", + "MetricUnit", + "MonitoringStatus", + "NetworkAdapterDHCPStatus", + "NetworkAdapterRDMAStatus", + "NetworkAdapterStatus", + "NetworkGroup", + "NodeStatus", + "OrderState", + "PlatformType", + "RoleStatus", + "RoleTypes", + "SSLStatus", + "ShareAccessProtocol", + "ShareAccessType", + "ShareStatus", + "SkuName", + "SkuRestrictionReasonCode", + "SkuTier", + "StorageAccountStatus", + "TimeGrain", + "TriggerEventType", + "UpdateOperation", + "UpdateOperationStage", + "UserType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_data_box_edge_management_client_enums.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_data_box_edge_management_client_enums.py index ea7aec1355bf..ccd430be8013 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_data_box_edge_management_client_enums.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_data_box_edge_management_client_enums.py @@ -6,67 +6,50 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of storage accessed on the storage account. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of storage accessed on the storage account.""" GENERAL_PURPOSE_STORAGE = "GeneralPurposeStorage" BLOB_STORAGE = "BlobStorage" -class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the alert. - """ + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert.""" INFORMATIONAL = "Informational" WARNING = "Warning" CRITICAL = "Critical" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The authentication type. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication type.""" INVALID = "Invalid" AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" -class AzureContainerDataFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Storage format used for the file represented by the share. - """ + +class AzureContainerDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage format used for the file represented by the share.""" BLOCK_BLOB = "BlockBlob" PAGE_BLOB = "PageBlob" AZURE_FILE = "AzureFile" -class ClientPermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed for the client. - """ + +class ClientPermissionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed for the client.""" NO_ACCESS = "NoAccess" READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the container. - """ + +class ContainerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the container.""" OK = "OK" OFFLINE = "Offline" @@ -74,9 +57,9 @@ class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the Data Box Edge/Gateway device. - """ + +class DataBoxEdgeDeviceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the Data Box Edge/Gateway device.""" READY_TO_SETUP = "ReadyToSetup" ONLINE = "Online" @@ -86,14 +69,16 @@ class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum PARTIALLY_DISCONNECTED = "PartiallyDisconnected" MAINTENANCE = "Maintenance" -class DataPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Data policy of the share. - """ + +class DataPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data policy of the share.""" CLOUD = "Cloud" LOCAL = "Local" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -103,40 +88,40 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DeviceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the Data Box Edge/Gateway device. - """ + +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the Data Box Edge/Gateway device.""" DATA_BOX_EDGE_DEVICE = "DataBoxEdgeDevice" -class DownloadPhase(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The download phase. - """ + +class DownloadPhase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The download phase.""" UNKNOWN = "Unknown" INITIALIZING = "Initializing" DOWNLOADING = "Downloading" VERIFYING = "Verifying" -class EncryptionAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The algorithm used to encrypt "Value". - """ + +class EncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The algorithm used to encrypt "Value".""" NONE = "None" AES256 = "AES256" RSAES_PKCS1_V1_5 = "RSAES_PKCS1_v_1_5" -class InstallRebootBehavior(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if updates are available and at least one of the updates needs a reboot. - """ + +class InstallRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if updates are available and at least one of the updates needs a reboot.""" NEVER_REBOOTS = "NeverReboots" REQUIRES_REBOOT = "RequiresReboot" REQUEST_REBOOT = "RequestReboot" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the job.""" INVALID = "Invalid" RUNNING = "Running" @@ -146,9 +131,9 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PAUSED = "Paused" SCHEDULED = "Scheduled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" INVALID = "Invalid" SCAN_FOR_UPDATES = "ScanForUpdates" @@ -157,9 +142,9 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REFRESH_SHARE = "RefreshShare" REFRESH_CONTAINER = "RefreshContainer" -class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric aggregation type. - """ + +class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric aggregation type.""" NOT_SPECIFIED = "NotSpecified" NONE = "None" @@ -169,16 +154,16 @@ class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) TOTAL = "Total" COUNT = "Count" -class MetricCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric category. - """ + +class MetricCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric category.""" CAPACITY = "Capacity" TRANSACTION = "Transaction" -class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric units. - """ + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric units.""" NOT_SPECIFIED = "NotSpecified" PERCENT = "Percent" @@ -189,45 +174,45 @@ class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BYTES_PER_SECOND = "BytesPerSecond" COUNT_PER_SECOND = "CountPerSecond" -class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current monitoring status of the share. - """ + +class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current monitoring status of the share.""" ENABLED = "Enabled" DISABLED = "Disabled" -class NetworkAdapterDHCPStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter has DHCP enabled. - """ + +class NetworkAdapterDHCPStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter has DHCP enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" -class NetworkAdapterRDMAStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is RDMA capable. - """ + +class NetworkAdapterRDMAStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is RDMA capable.""" INCAPABLE = "Incapable" CAPABLE = "Capable" -class NetworkAdapterStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is valid. - """ + +class NetworkAdapterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is valid.""" INACTIVE = "Inactive" ACTIVE = "Active" -class NetworkGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The network group. - """ + +class NetworkGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network group.""" NONE = "None" NON_RDMA = "NonRDMA" RDMA = "RDMA" -class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the individual node - """ + +class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the individual node.""" UNKNOWN = "Unknown" UP = "Up" @@ -235,9 +220,9 @@ class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REBOOTING = "Rebooting" SHUTTING_DOWN = "ShuttingDown" -class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the order as per the allowed status types. - """ + +class OrderState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the order as per the allowed status types.""" UNTRACKED = "Untracked" AWAITING_FULFILMENT = "AwaitingFulfilment" @@ -254,45 +239,47 @@ class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SHIPPED_BACK = "ShippedBack" COLLECTED_AT_MICROSOFT = "CollectedAtMicrosoft" -class PlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Host OS supported by the IoT role. - """ + +class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host OS supported by the IoT role.""" WINDOWS = "Windows" LINUX = "Linux" -class RoleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Role status. - """ + +class RoleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Role status.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RoleTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleTypes.""" IOT = "IOT" ASA = "ASA" FUNCTIONS = "Functions" COGNITIVE = "Cognitive" -class ShareAccessProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Access protocol to be used by the share. - """ + +class ShareAccessProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access protocol to be used by the share.""" SMB = "SMB" NFS = "NFS" -class ShareAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed on the share for this user. - """ + +class ShareAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed on the share for this user.""" CHANGE = "Change" READ = "Read" CUSTOM = "Custom" -class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the share. - """ + +class ShareStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the share.""" OFFLINE = "Offline" UNKNOWN = "Unknown" @@ -300,9 +287,9 @@ class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku name - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku name.""" GATEWAY = "Gateway" EDGE = "Edge" @@ -314,29 +301,29 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): TEA4_NODE_UPS_HEATER = "TEA_4Node_UPS_Heater" TMA = "TMA" -class SkuRestrictionReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The SKU restriction reason. - """ + +class SkuRestrictionReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU restriction reason.""" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" QUOTA_ID = "QuotaId" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku tier - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku tier.""" STANDARD = "Standard" -class SSLStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Signifies whether SSL needs to be enabled or not. - """ + +class SSLStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Signifies whether SSL needs to be enabled or not.""" ENABLED = "Enabled" DISABLED = "Disabled" -class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the storage account - """ + +class StorageAccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the storage account.""" OK = "OK" OFFLINE = "Offline" @@ -344,7 +331,9 @@ class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class TimeGrain(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TimeGrain.""" PT1_M = "PT1M" PT5_M = "PT5M" @@ -355,25 +344,25 @@ class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PT12_H = "PT12H" PT1_D = "PT1D" -class TriggerEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Trigger Kind. - """ + +class TriggerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trigger Kind.""" FILE_EVENT = "FileEvent" PERIODIC_TIMER_EVENT = "PeriodicTimerEvent" -class UpdateOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current update operation. - """ + +class UpdateOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current update operation.""" NONE = "None" SCAN = "Scan" DOWNLOAD = "Download" INSTALL = "Install" -class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current stage of the update operation. - """ + +class UpdateOperationStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current stage of the update operation.""" UNKNOWN = "Unknown" INITIAL = "Initial" @@ -393,9 +382,9 @@ class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESCAN_COMPLETE = "RescanComplete" RESCAN_FAILED = "RescanFailed" -class UserType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of the user. - """ + +class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the user.""" SHARE = "Share" LOCAL_MANAGEMENT = "LocalManagement" diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_models.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_models.py deleted file mode 100644 index de25c17e49f4..000000000000 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_models.py +++ /dev/null @@ -1,3305 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class Address(msrest.serialization.Model): - """The shipping address of the customer. - - All required parameters must be populated in order to send to Azure. - - :param address_line1: Required. The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: Required. The postal code. - :type postal_code: str - :param city: Required. The city name. - :type city: str - :param state: Required. The state name. - :type state: str - :param country: Required. The country name. - :type country: str - """ - - _validation = { - 'address_line1': {'required': True}, - 'postal_code': {'required': True}, - 'city': {'required': True}, - 'state': {'required': True}, - 'country': {'required': True}, - } - - _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Address, self).__init__(**kwargs) - self.address_line1 = kwargs['address_line1'] - self.address_line2 = kwargs.get('address_line2', None) - self.address_line3 = kwargs.get('address_line3', None) - self.postal_code = kwargs['postal_code'] - self.city = kwargs['city'] - self.state = kwargs['state'] - self.country = kwargs['country'] - - -class ARMBaseModel(msrest.serialization.Model): - """Represents the base class for all object models. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Alert(ARMBaseModel): - """Alert on the data box edge/gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar title: Alert title. - :vartype title: str - :ivar alert_type: Alert type. - :vartype alert_type: str - :ivar appeared_at_date_time: UTC time when the alert appeared. - :vartype appeared_at_date_time: ~datetime.datetime - :ivar recommendation: Alert recommendation. - :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", - "Critical". - :vartype severity: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AlertSeverity - :ivar error_details: Error details of the alert. - :vartype error_details: ~azure.mgmt.databoxedge.v2019_08_01.models.AlertErrorDetails - :ivar detailed_information: Alert details. - :vartype detailed_information: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) - self.title = None - self.alert_type = None - self.appeared_at_date_time = None - self.recommendation = None - self.severity = None - self.error_details = None - self.detailed_information = None - - -class AlertErrorDetails(msrest.serialization.Model): - """Error details for the alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code. - :vartype error_code: str - :ivar error_message: Error Message. - :vartype error_message: str - :ivar occurrences: Number of occurrences. - :vartype occurrences: int - """ - - _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) - self.error_code = None - self.error_message = None - self.occurrences = None - - -class AlertList(msrest.serialization.Model): - """Collection of alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Alert] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class AsymmetricEncryptedSecret(msrest.serialization.Model): - """Represent the secrets intended for encryption with asymmetric key pair. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the - value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or - ~azure.mgmt.databoxedge.v2019_08_01.models.EncryptionAlgorithm - """ - - _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) - self.value = kwargs['value'] - self.encryption_cert_thumbprint = kwargs.get('encryption_cert_thumbprint', None) - self.encryption_algorithm = kwargs['encryption_algorithm'] - - -class Authentication(msrest.serialization.Model): - """Authentication mechanism for IoT devices. - - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2019_08_01.models.SymmetricKey - """ - - _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, - } - - def __init__( - self, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) - self.symmetric_key = kwargs.get('symmetric_key', None) - - -class AzureContainerInfo(msrest.serialization.Model): - """Azure container mapping of the endpoint. - - All required parameters must be populated in order to send to Azure. - - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerDataFormat - """ - - _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, - } - - _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) - self.storage_account_credential_id = kwargs['storage_account_credential_id'] - self.container_name = kwargs['container_name'] - self.data_format = kwargs['data_format'] - - -class BandwidthSchedule(ARMBaseModel): - """The bandwidth schedule details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2019_08_01.models.DayOfWeek] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) - self.start = kwargs['start'] - self.stop = kwargs['stop'] - self.rate_in_mbps = kwargs['rate_in_mbps'] - self.days = kwargs['days'] - - -class BandwidthSchedulesList(msrest.serialization.Model): - """The collection of bandwidth schedules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of bandwidth schedules. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ClientAccessRight(msrest.serialization.Model): - """The mapping between a particular client IP and the type of access client has on the NFS share. - - All required parameters must be populated in order to send to Azure. - - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ClientPermissionType - """ - - _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, - } - - _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) - self.client = kwargs['client'] - self.access_permission = kwargs['access_permission'] - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2019_08_01.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class ContactDetails(msrest.serialization.Model): - """Contains all the contact details of the customer. - - All required parameters must be populated in order to send to Azure. - - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] - """ - - _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) - self.contact_person = kwargs['contact_person'] - self.company_name = kwargs['company_name'] - self.phone = kwargs['phone'] - self.email_list = kwargs['email_list'] - - -class Container(ARMBaseModel): - """Represents a container on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". - :vartype container_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerDataFormat - :ivar refresh_details: Details of the refresh job on this container. - :vartype refresh_details: ~azure.mgmt.databoxedge.v2019_08_01.models.RefreshDetails - :ivar created_date_time: The UTC time when container got created. - :vartype created_date_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Container, self).__init__(**kwargs) - self.container_status = None - self.data_format = kwargs['data_format'] - self.refresh_details = None - self.created_date_time = None - - -class ContainerList(msrest.serialization.Model): - """Collection of all the containers on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of containers. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Container] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevice(ARMBaseModel): - """The Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure - geographical region (for example, West US, East US, or Southeast Asia). The geographical region - of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2019_08_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or - ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDeviceStatus - :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. - :vartype serial_number: str - :param description: The Description of the Data Box Edge/Gateway device. - :type description: str - :param model_description: The description of the Data Box Edge/Gateway device model. - :type model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". - :vartype device_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DeviceType - :param friendly_name: The Data Box Edge/Gateway device name. - :type friendly_name: str - :ivar culture: The Data Box Edge/Gateway device culture. - :vartype culture: str - :ivar device_model: The Data Box Edge/Gateway device model. - :vartype device_model: str - :ivar device_software_version: The Data Box Edge/Gateway device software version. - :vartype device_software_version: str - :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long - :ivar time_zone: The Data Box Edge/Gateway device timezone. - :vartype time_zone: str - :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). - :vartype device_hcs_version: str - :ivar configured_role_types: Type of compute roles configured. - :vartype configured_role_types: list[str or - ~azure.mgmt.databoxedge.v2019_08_01.models.RoleTypes] - :ivar node_count: The number of nodes in the cluster. - :vartype node_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'serial_number': {'readonly': True}, - 'device_type': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - self.etag = kwargs.get('etag', None) - self.data_box_edge_device_status = kwargs.get('data_box_edge_device_status', None) - self.serial_number = None - self.description = kwargs.get('description', None) - self.model_description = kwargs.get('model_description', None) - self.device_type = None - self.friendly_name = kwargs.get('friendly_name', None) - self.culture = None - self.device_model = None - self.device_software_version = None - self.device_local_capacity = None - self.time_zone = None - self.device_hcs_version = None - self.configured_role_types = None - self.node_count = None - - -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): - """The extended Info of the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to - encrypt any secret. - :type encryption_key: str - :ivar resource_key: The Resource ID of the Resource. - :vartype resource_key: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) - self.encryption_key_thumbprint = kwargs.get('encryption_key_thumbprint', None) - self.encryption_key = kwargs.get('encryption_key', None) - self.resource_key = None - - -class DataBoxEdgeDeviceList(msrest.serialization.Model): - """The collection of Data Box Edge/Gateway devices. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Data Box Edge/Gateway devices. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevicePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device patch. - - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class Trigger(ARMBaseModel): - """Trigger details. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.TriggerEventType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } - - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.kind = 'Trigger' # type: str - - -class FileEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2019_08_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2019_08_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class FileSourceInfo(msrest.serialization.Model): - """File source details. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. File share ID. - :type share_id: str - """ - - _validation = { - 'share_id': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - - -class IoTDeviceInfo(msrest.serialization.Model): - """Metadata of IoT device/IoT Edge device to be configured. - - All required parameters must be populated in order to send to Azure. - - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: IoT device authentication info. - :type authentication: ~azure.mgmt.databoxedge.v2019_08_01.models.Authentication - """ - - _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) - self.device_id = kwargs['device_id'] - self.io_t_host_hub = kwargs['io_t_host_hub'] - self.io_t_host_hub_id = kwargs.get('io_t_host_hub_id', None) - self.authentication = kwargs.get('authentication', None) - - -class Role(ARMBaseModel): - """Compute role. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: IoTRole. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleTypes - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'IOT': 'IoTRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str - - -class IoTRole(Role): - """Compute role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleTypes - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", - "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2019_08_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2019_08_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_08_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2019_08_01.models.MountPointMap] - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.io_t_device_details = kwargs.get('io_t_device_details', None) - self.io_t_edge_device_details = kwargs.get('io_t_edge_device_details', None) - self.share_mappings = kwargs.get('share_mappings', None) - self.role_status = kwargs.get('role_status', None) - - -class Ipv4Config(msrest.serialization.Model): - """Details related to the IPv4 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv4 address of the network adapter. - :vartype ip_address: str - :ivar subnet: The IPv4 subnet of the network adapter. - :vartype subnet: str - :ivar gateway: The IPv4 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) - self.ip_address = None - self.subnet = None - self.gateway = None - - -class Ipv6Config(msrest.serialization.Model): - """Details related to the IPv6 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv6 address of the network adapter. - :vartype ip_address: str - :ivar prefix_length: The IPv6 prefix of the network adapter. - :vartype prefix_length: int - :ivar gateway: The IPv6 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) - self.ip_address = None - self.prefix_length = None - self.gateway = None - - -class Job(msrest.serialization.Model): - """A device job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The name of the object. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.JobStatus - :ivar start_time: The UTC date and time at which the job started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The UTC date and time at which the job completed. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: The percentage of the job that is complete. - :vartype percent_complete: int - :ivar error: The error details. - :vartype error: ~azure.mgmt.databoxedge.v2019_08_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer". - :vartype job_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", - "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", - "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". - :vartype current_stage: str or ~azure.mgmt.databoxedge.v2019_08_01.models.UpdateOperationStage - :ivar download_progress: The download progress. - :vartype download_progress: ~azure.mgmt.databoxedge.v2019_08_01.models.UpdateDownloadProgress - :ivar install_progress: The install progress. - :vartype install_progress: ~azure.mgmt.databoxedge.v2019_08_01.models.UpdateInstallProgress - :ivar total_refresh_errors: Total number of errors encountered during the refresh process. - :vartype total_refresh_errors: int - :ivar error_manifest_file: Local share/remote container relative path to the error manifest - file of the refresh. - :vartype error_manifest_file: str - :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. - :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_time = None - self.end_time = None - self.percent_complete = None - self.error = None - self.job_type = None - self.current_stage = None - self.download_progress = None - self.install_progress = None - self.total_refresh_errors = None - self.error_manifest_file = None - self.refreshed_entity_id = None - self.folder = kwargs.get('folder', None) - - -class JobErrorDetails(msrest.serialization.Model): - """The job error information containing the list of job errors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_details: The error details. - :vartype error_details: list[~azure.mgmt.databoxedge.v2019_08_01.models.JobErrorItem] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) - self.error_details = None - self.code = None - self.message = None - - -class JobErrorItem(msrest.serialization.Model): - """The job error items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendations: The recommended actions. - :vartype recommendations: list[str] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) - self.recommendations = None - self.code = None - self.message = None - - -class MetricDimensionV1(msrest.serialization.Model): - """Metric Dimension v1. - - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimensionV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecificationV1(msrest.serialization.Model): - """Metric specification version 1. - - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2019_08_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or - ~azure.mgmt.databoxedge.v2019_08_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or - ~azure.mgmt.databoxedge.v2019_08_01.models.MetricAggregationType] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.dimensions = kwargs.get('dimensions', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - - -class MountPointMap(msrest.serialization.Model): - """The share mount point. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str - :ivar role_id: ID of the role to which share is mounted. - :vartype role_id: str - :ivar mount_point: Mount point for the share. - :vartype mount_point: str - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive". - :vartype role_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleTypes - """ - - _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'role_type': {'readonly': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.role_id = None - self.mount_point = None - self.role_type = None - - -class NetworkAdapter(msrest.serialization.Model): - """Represents the networkAdapter on a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar adapter_id: Instance ID of network adapter. - :vartype adapter_id: str - :ivar adapter_position: Hardware position of network adapter. - :vartype adapter_position: ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterPosition - :ivar index: Logical index of the adapter. - :vartype index: int - :ivar node_id: Node ID of the network adapter. - :vartype node_id: str - :ivar network_adapter_name: Network adapter name. - :vartype network_adapter_name: str - :ivar label: Hardware label for the adapter. - :vartype label: str - :ivar mac_address: MAC address. - :vartype mac_address: str - :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". - :vartype status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterDHCPStatus - :ivar ipv4_configuration: The IPv4 configuration of the network adapter. - :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2019_08_01.models.Ipv4Config - :ivar ipv6_configuration: The IPv6 configuration of the network adapter. - :vartype ipv6_configuration: ~azure.mgmt.databoxedge.v2019_08_01.models.Ipv6Config - :ivar ipv6_link_local_address: The IPv6 local address. - :vartype ipv6_link_local_address: str - :ivar dns_servers: The list of DNS Servers of the device. - :vartype dns_servers: list[str] - """ - - _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) - self.adapter_id = None - self.adapter_position = None - self.index = None - self.node_id = None - self.network_adapter_name = None - self.label = None - self.mac_address = None - self.link_speed = None - self.status = None - self.rdma_status = kwargs.get('rdma_status', None) - self.dhcp_status = kwargs.get('dhcp_status', None) - self.ipv4_configuration = None - self.ipv6_configuration = None - self.ipv6_link_local_address = None - self.dns_servers = None - - -class NetworkAdapterPosition(msrest.serialization.Model): - """The network adapter position. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". - :vartype network_group: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkGroup - :ivar port: The port. - :vartype port: int - """ - - _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, - } - - _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) - self.network_group = None - self.port = None - - -class NetworkSettings(ARMBaseModel): - """The network settings of a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar network_adapters: The network adapter list on the device. - :vartype network_adapters: list[~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapter] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) - self.network_adapters = None - - -class Node(ARMBaseModel): - """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) - self.node_status = None - self.node_chassis_serial_number = None - self.node_serial_number = None - self.node_display_name = None - self.node_friendly_software_version = None - self.node_hcs_version = None - self.node_instance_id = None - - -class NodeList(msrest.serialization.Model): - """Collection of Nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Nodes. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Node] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) - self.value = None - - -class Operation(msrest.serialization.Model): - """Operations. - - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2019_08_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2019_08_01.models.ServiceSpecification - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationDisplay(msrest.serialization.Model): - """Operation display properties. - - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str - """ - - _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 = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """The list of operations used for the discovery of available provider operations. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class Order(ARMBaseModel): - """The order details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2019_08_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2019_08_01.models.Address - :param current_status: Current status of the order. - :type current_status: ~azure.mgmt.databoxedge.v2019_08_01.models.OrderStatus - :ivar order_history: List of status changes in the order. - :vartype order_history: list[~azure.mgmt.databoxedge.v2019_08_01.models.OrderStatus] - :ivar serial_number: Serial number of the device. - :vartype serial_number: str - :ivar delivery_tracking_info: Tracking information for the package delivered to the customer - whether it has an original or a replacement device. - :vartype delivery_tracking_info: list[~azure.mgmt.databoxedge.v2019_08_01.models.TrackingInfo] - :ivar return_tracking_info: Tracking information for the package returned from the customer - whether it has an original or a replacement device. - :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2019_08_01.models.TrackingInfo] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(Order, self).__init__(**kwargs) - self.contact_information = kwargs.get('contact_information', None) - self.shipping_address = kwargs.get('shipping_address', None) - self.current_status = kwargs.get('current_status', None) - self.order_history = None - self.serial_number = None - self.delivery_tracking_info = None - self.return_tracking_info = None - - -class OrderList(msrest.serialization.Model): - """List of order entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of orders. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Order] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OrderStatus(msrest.serialization.Model): - """Represents a single status change. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft". - :type status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.OrderState - :ivar update_date_time: Time of status update. - :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str - :ivar additional_order_details: Dictionary to hold generic information which is not stored - by the already existing properties. - :vartype additional_order_details: dict[str, str] - """ - - _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'additional_order_details': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) - self.status = kwargs['status'] - self.update_date_time = None - self.comments = kwargs.get('comments', None) - self.additional_order_details = None - - -class PeriodicTimerEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2019_08_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2019_08_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class PeriodicTimerSourceInfo(msrest.serialization.Model): - """Periodic timer event source. - - All required parameters must be populated in order to send to Azure. - - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str - """ - - _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) - self.start_time = kwargs['start_time'] - self.schedule = kwargs['schedule'] - self.topic = kwargs.get('topic', None) - - -class RefreshDetails(msrest.serialization.Model): - """Fields for tracking refresh job on the share or container. - - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or - container, this field indicates the ARM resource ID of that job. The field is empty if no job - is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh - job on this particular share or container, if any. This could be a failed job or a successful - job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or - container,if any. This could be a failed job or a successful job. - :type last_job: str - """ - - _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RefreshDetails, self).__init__(**kwargs) - self.in_progress_refresh_job_id = kwargs.get('in_progress_refresh_job_id', None) - self.last_completed_refresh_job_time_in_utc = kwargs.get('last_completed_refresh_job_time_in_utc', None) - self.error_manifest_file = kwargs.get('error_manifest_file', None) - self.last_job = kwargs.get('last_job', None) - - -class ResourceTypeSku(msrest.serialization.Model): - """SkuInformation object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA". - :vartype name: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuName - :ivar kind: The Sku kind. - :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". - :vartype tier: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuTier - :ivar family: The Sku family. - :vartype family: str - :ivar locations: Availability of the SKU for the region. - :vartype locations: list[str] - :ivar api_versions: The API versions in which SKU is available. - :vartype api_versions: list[str] - :ivar location_info: Availability of the SKU for the location/zone. - :vartype location_info: list[~azure.mgmt.databoxedge.v2019_08_01.models.SkuLocationInfo] - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2019_08_01.models.SkuCost] - :ivar restrictions: Restrictions of the SKU availability. - :vartype restrictions: list[~azure.mgmt.databoxedge.v2019_08_01.models.SkuRestriction] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'restrictions': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'restrictions': {'key': 'restrictions', 'type': '[SkuRestriction]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) - self.resource_type = None - self.name = None - self.kind = None - self.tier = None - self.family = None - self.locations = None - self.api_versions = None - self.location_info = None - self.costs = None - self.restrictions = None - - -class RoleList(msrest.serialization.Model): - """Collection of all the roles on the Data Box Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Role] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RoleSinkInfo(msrest.serialization.Model): - """Compute role against which events will be raised. - - All required parameters must be populated in order to send to Azure. - - :param role_id: Required. Compute role ID. - :type role_id: str - """ - - _validation = { - 'role_id': {'required': True}, - } - - _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) - self.role_id = kwargs['role_id'] - - -class SecuritySettings(ARMBaseModel): - """The security settings of a device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: - ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) - self.device_admin_password = kwargs['device_admin_password'] - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification. - - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: - list[~azure.mgmt.databoxedge.v2019_08_01.models.MetricSpecificationV1] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Share(ARMBaseModel): - """Represents a share on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share - (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2019_08_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the - share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2019_08_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2019_08_01.models.RefreshDetails - :ivar share_mappings: Share mount point to the role. - :vartype share_mappings: list[~azure.mgmt.databoxedge.v2019_08_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DataPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Share, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.share_status = kwargs['share_status'] - self.monitoring_status = kwargs['monitoring_status'] - self.azure_container_info = kwargs.get('azure_container_info', None) - self.access_protocol = kwargs['access_protocol'] - self.user_access_rights = kwargs.get('user_access_rights', None) - self.client_access_rights = kwargs.get('client_access_rights', None) - self.refresh_details = kwargs.get('refresh_details', None) - self.share_mappings = None - self.data_policy = kwargs.get('data_policy', None) - - -class ShareAccessRight(msrest.serialization.Model): - """Specifies the mapping between this particular user and the type of access he has on shares on this device. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessType - """ - - _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.access_type = kwargs['access_type'] - - -class ShareList(msrest.serialization.Model): - """Collection of all the shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of shares. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Share] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Sku(msrest.serialization.Model): - """The SKU type. - - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA". - :type name: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuTier - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - - -class SkuCost(msrest.serialization.Model): - """The metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The cost quantity. - :vartype quantity: long - :ivar extended_unit: Restriction of the SKU for the location/zone. - :vartype extended_unit: str - """ - - _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, - } - - _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) - self.meter_id = None - self.quantity = None - self.extended_unit = None - - -class SkuInformationList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceType Sku. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.ResourceTypeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SkuLocationInfo(msrest.serialization.Model): - """The location info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The location. - :vartype location: str - :ivar zones: The zones. - :vartype zones: list[str] - :ivar sites: The sites. - :vartype sites: list[str] - """ - - _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) - self.location = None - self.zones = None - self.sites = None - - -class SkuRestriction(msrest.serialization.Model): - """The restrictions because of which SKU cannot be used. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the restriction. - :vartype type: str - :ivar values: The locations where sku is restricted. - :vartype values: list[str] - :ivar reason_code: The SKU restriction reason. Possible values include: - "NotAvailableForSubscription", "QuotaId". - :vartype reason_code: str or - ~azure.mgmt.databoxedge.v2019_08_01.models.SkuRestrictionReasonCode - :ivar restriction_info: Restriction of the SKU for the location/zone. - :vartype restriction_info: ~azure.mgmt.databoxedge.v2019_08_01.models.SkuRestrictionInfo - """ - - _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, - 'reason_code': {'readonly': True}, - 'restriction_info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'SkuRestrictionInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuRestriction, self).__init__(**kwargs) - self.type = None - self.values = None - self.reason_code = None - self.restriction_info = None - - -class SkuRestrictionInfo(msrest.serialization.Model): - """The restriction info with locations and zones. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar locations: The locations. - :vartype locations: list[str] - :ivar zones: The zones. - :vartype zones: list[str] - """ - - _validation = { - 'locations': {'readonly': True}, - 'zones': {'readonly': True}, - } - - _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuRestrictionInfo, self).__init__(**kwargs) - self.locations = None - self.zones = None - - -class StorageAccount(ARMBaseModel): - """Represents a Storage Account on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or - ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountStatus - :param data_policy: Data policy of the storage Account. Possible values include: "Cloud", - "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str - :ivar blob_endpoint: BlobEndpoint of Storage Account. - :vartype blob_endpoint: str - :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy - set to Cloud. - :vartype container_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccount, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.storage_account_status = kwargs.get('storage_account_status', None) - self.data_policy = kwargs.get('data_policy', None) - self.storage_account_credential_id = kwargs.get('storage_account_credential_id', None) - self.blob_endpoint = None - self.container_count = None - - -class StorageAccountCredential(ARMBaseModel): - """The storage account credential. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredential, self).__init__(**kwargs) - self.alias = kwargs['alias'] - self.user_name = kwargs.get('user_name', None) - self.account_key = kwargs.get('account_key', None) - self.connection_string = kwargs.get('connection_string', None) - self.ssl_status = kwargs['ssl_status'] - self.blob_domain_name = kwargs.get('blob_domain_name', None) - self.account_type = kwargs['account_type'] - self.storage_account_id = kwargs.get('storage_account_id', None) - - -class StorageAccountCredentialList(msrest.serialization.Model): - """The collection of storage account credentials. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class StorageAccountList(msrest.serialization.Model): - """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of storageAccounts. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SymmetricKey(msrest.serialization.Model): - """Symmetric key for authentication. - - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret - """ - - _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) - self.connection_string = kwargs.get('connection_string', None) - - -class TrackingInfo(msrest.serialization.Model): - """Tracking courier information. - - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str - """ - - _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackingInfo, self).__init__(**kwargs) - self.serial_number = kwargs.get('serial_number', None) - self.carrier_name = kwargs.get('carrier_name', None) - self.tracking_id = kwargs.get('tracking_id', None) - self.tracking_url = kwargs.get('tracking_url', None) - - -class TriggerList(msrest.serialization.Model): - """Collection of all trigger on the data box edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of triggers. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Trigger] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UpdateDownloadProgress(msrest.serialization.Model): - """Details about the download progress of update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". - :vartype download_phase: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DownloadPhase - :ivar percent_complete: Percentage of completion. - :vartype percent_complete: int - :ivar total_bytes_to_download: Total bytes to download. - :vartype total_bytes_to_download: float - :ivar total_bytes_downloaded: Total bytes downloaded. - :vartype total_bytes_downloaded: float - :ivar number_of_updates_to_download: Number of updates to download. - :vartype number_of_updates_to_download: int - :ivar number_of_updates_downloaded: Number of updates downloaded. - :vartype number_of_updates_downloaded: int - """ - - _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, - } - - _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) - self.download_phase = None - self.percent_complete = None - self.total_bytes_to_download = None - self.total_bytes_downloaded = None - self.number_of_updates_to_download = None - self.number_of_updates_downloaded = None - - -class UpdateInstallProgress(msrest.serialization.Model): - """Progress details during installation of updates. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar percent_complete: Percentage completed. - :vartype percent_complete: int - :ivar number_of_updates_to_install: Number of updates to install. - :vartype number_of_updates_to_install: int - :ivar number_of_updates_installed: Number of updates installed. - :vartype number_of_updates_installed: int - """ - - _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, - } - - _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) - self.percent_complete = None - self.number_of_updates_to_install = None - self.number_of_updates_installed = None - - -class UpdateSummary(ARMBaseModel): - """Details about ongoing updates and availability of updates on the device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed - (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime - :ivar last_completed_download_job_date_time: The time when the last Download job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_download_job_date_time: ~datetime.datetime - :ivar last_completed_install_job_date_time: The time when the last Install job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_install_job_date_time: ~datetime.datetime - :ivar total_number_of_updates_available: The number of updates available for the current device - version as per the last device scan. - :vartype total_number_of_updates_available: int - :ivar total_number_of_updates_pending_download: The total number of items pending download. - :vartype total_number_of_updates_pending_download: int - :ivar total_number_of_updates_pending_install: The total number of items pending install. - :vartype total_number_of_updates_pending_install: int - :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.databoxedge.v2019_08_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". - :vartype ongoing_update_operation: str or - ~azure.mgmt.databoxedge.v2019_08_01.models.UpdateOperation - :ivar in_progress_download_job_id: The job ID of the download job in progress. - :vartype in_progress_download_job_id: str - :ivar in_progress_install_job_id: The job ID of the install job in progress. - :vartype in_progress_install_job_id: str - :ivar in_progress_download_job_started_date_time: The time when the currently running download - (if any) started. - :vartype in_progress_download_job_started_date_time: ~datetime.datetime - :ivar in_progress_install_job_started_date_time: The time when the currently running install - (if any) started. - :vartype in_progress_install_job_started_date_time: ~datetime.datetime - :ivar update_titles: The list of updates available for install. - :vartype update_titles: list[str] - :ivar total_update_size_in_bytes: The total size of updates available for download in bytes. - :vartype total_update_size_in_bytes: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateSummary, self).__init__(**kwargs) - self.device_version_number = kwargs.get('device_version_number', None) - self.friendly_device_version_name = kwargs.get('friendly_device_version_name', None) - self.device_last_scanned_date_time = kwargs.get('device_last_scanned_date_time', None) - self.last_completed_scan_job_date_time = kwargs.get('last_completed_scan_job_date_time', None) - self.last_completed_download_job_date_time = None - self.last_completed_install_job_date_time = None - self.total_number_of_updates_available = None - self.total_number_of_updates_pending_download = None - self.total_number_of_updates_pending_install = None - self.reboot_behavior = None - self.ongoing_update_operation = None - self.in_progress_download_job_id = None - self.in_progress_install_job_id = None - self.in_progress_download_job_started_date_time = None - self.in_progress_install_job_started_date_time = None - self.update_titles = None - self.total_update_size_in_bytes = None - - -class UploadCertificateRequest(msrest.serialization.Model): - """The upload certificate request. - - All required parameters must be populated in order to send to Azure. - - :param authentication_type: The authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str - """ - - _validation = { - 'certificate': {'required': True}, - } - - _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) - self.authentication_type = kwargs.get('authentication_type', None) - self.certificate = kwargs['certificate'] - - -class UploadCertificateResponse(msrest.serialization.Model): - """The upload registration certificate response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param auth_type: Specifies authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AuthenticationType - :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. - :vartype resource_id: str - :ivar aad_authority: Azure Active Directory tenant authority. - :vartype aad_authority: str - :ivar aad_tenant_id: Azure Active Directory tenant ID. - :vartype aad_tenant_id: str - :ivar service_principal_client_id: Azure Active Directory service principal client ID. - :vartype service_principal_client_id: str - :ivar service_principal_object_id: Azure Active Directory service principal object ID. - :vartype service_principal_object_id: str - :ivar azure_management_endpoint_audience: The azure management endpoint audience. - :vartype azure_management_endpoint_audience: str - :ivar aad_audience: Identifier of the target resource that is the recipient of the requested - token. - :vartype aad_audience: str - """ - - _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, - } - - _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) - self.auth_type = kwargs.get('auth_type', None) - self.resource_id = None - self.aad_authority = None - self.aad_tenant_id = None - self.service_principal_client_id = None - self.service_principal_object_id = None - self.azure_management_endpoint_audience = None - self.aad_audience = None - - -class User(ARMBaseModel): - """Represents a user who has access to one or more shares on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret - :param share_access_rights: List of shares that the user has rights on. This field should not - be specified during user creation. - :type share_access_rights: list[~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessRight] - :param user_type: Required. Type of the user. Possible values include: "Share", - "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.UserType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'user_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.encrypted_password = kwargs.get('encrypted_password', None) - self.share_access_rights = kwargs.get('share_access_rights', None) - self.user_type = kwargs['user_type'] - - -class UserAccessRight(msrest.serialization.Model): - """The mapping between a particular user and the access type on the SMB share. - - All required parameters must be populated in order to send to Azure. - - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessType - """ - - _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) - self.user_id = kwargs['user_id'] - self.access_type = kwargs['access_type'] - - -class UserList(msrest.serialization.Model): - """Collection of users. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of users. - :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.User] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) - self.value = None - self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_models_py3.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_models_py3.py index 8127bc9f7fdb..9256de6c743a 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_models_py3.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,50 +8,52 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._data_box_edge_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Address(msrest.serialization.Model): +class Address(_serialization.Model): """The shipping address of the customer. All required parameters must be populated in order to send to Azure. - :param address_line1: Required. The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: Required. The postal code. - :type postal_code: str - :param city: Required. The city name. - :type city: str - :param state: Required. The state name. - :type state: str - :param country: Required. The country name. - :type country: str + :ivar address_line1: The address line1. Required. + :vartype address_line1: str + :ivar address_line2: The address line2. + :vartype address_line2: str + :ivar address_line3: The address line3. + :vartype address_line3: str + :ivar postal_code: The postal code. Required. + :vartype postal_code: str + :ivar city: The city name. Required. + :vartype city: str + :ivar state: The state name. Required. + :vartype state: str + :ivar country: The country name. Required. + :vartype country: str """ _validation = { - 'address_line1': {'required': True}, - 'postal_code': {'required': True}, - 'city': {'required': True}, - 'state': {'required': True}, - 'country': {'required': True}, + "address_line1": {"required": True}, + "postal_code": {"required": True}, + "city": {"required": True}, + "state": {"required": True}, + "country": {"required": True}, } _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, + "address_line1": {"key": "addressLine1", "type": "str"}, + "address_line2": {"key": "addressLine2", "type": "str"}, + "address_line3": {"key": "addressLine3", "type": "str"}, + "postal_code": {"key": "postalCode", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "country": {"key": "country", "type": "str"}, } def __init__( @@ -65,7 +68,23 @@ def __init__( address_line3: Optional[str] = None, **kwargs ): - super(Address, self).__init__(**kwargs) + """ + :keyword address_line1: The address line1. Required. + :paramtype address_line1: str + :keyword address_line2: The address line2. + :paramtype address_line2: str + :keyword address_line3: The address line3. + :paramtype address_line3: str + :keyword postal_code: The postal code. Required. + :paramtype postal_code: str + :keyword city: The city name. Required. + :paramtype city: str + :keyword state: The state name. Required. + :paramtype state: str + :keyword country: The country name. Required. + :paramtype country: str + """ + super().__init__(**kwargs) self.address_line1 = address_line1 self.address_line2 = address_line2 self.address_line3 = address_line3 @@ -75,7 +94,7 @@ def __init__( self.country = country -class ARMBaseModel(msrest.serialization.Model): +class ARMBaseModel(_serialization.Model): """Represents the base class for all object models. Variables are only populated by the server, and will be ignored when sending a request. @@ -89,22 +108,20 @@ class ARMBaseModel(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -129,7 +146,7 @@ class Alert(ARMBaseModel): :vartype appeared_at_date_time: ~datetime.datetime :ivar recommendation: Alert recommendation. :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", + :ivar severity: Severity of the alert. Known values are: "Informational", "Warning", and "Critical". :vartype severity: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AlertSeverity :ivar error_details: Error details of the alert. @@ -139,36 +156,34 @@ class Alert(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "title": {"readonly": True}, + "alert_type": {"readonly": True}, + "appeared_at_date_time": {"readonly": True}, + "recommendation": {"readonly": True}, + "severity": {"readonly": True}, + "error_details": {"readonly": True}, + "detailed_information": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "title": {"key": "properties.title", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "appeared_at_date_time": {"key": "properties.appearedAtDateTime", "type": "iso-8601"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "error_details": {"key": "properties.errorDetails", "type": "AlertErrorDetails"}, + "detailed_information": {"key": "properties.detailedInformation", "type": "{str}"}, } - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.title = None self.alert_type = None self.appeared_at_date_time = None @@ -178,7 +193,7 @@ def __init__( self.detailed_information = None -class AlertErrorDetails(msrest.serialization.Model): +class AlertErrorDetails(_serialization.Model): """Error details for the alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -192,28 +207,26 @@ class AlertErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, + "error_code": {"readonly": True}, + "error_message": {"readonly": True}, + "occurrences": {"readonly": True}, } _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "occurrences": {"key": "occurrences", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_code = None self.error_message = None self.occurrences = None -class AlertList(msrest.serialization.Model): +class AlertList(_serialization.Model): """Collection of alerts. Variables are only populated by the server, and will be ignored when sending a request. @@ -225,112 +238,121 @@ class AlertList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class AsymmetricEncryptedSecret(msrest.serialization.Model): +class AsymmetricEncryptedSecret(_serialization.Model): """Represent the secrets intended for encryption with asymmetric key pair. All required parameters must be populated in order to send to Azure. - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + :ivar value: The value of the secret. Required. + :vartype value: str + :ivar encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or + :vartype encryption_cert_thumbprint: str + :ivar encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values are: + "None", "AES256", and "RSAES_PKCS1_v_1_5". + :vartype encryption_algorithm: str or ~azure.mgmt.databoxedge.v2019_08_01.models.EncryptionAlgorithm """ _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, + "value": {"required": True}, + "encryption_algorithm": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "encryption_cert_thumbprint": {"key": "encryptionCertThumbprint", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, } def __init__( self, *, value: str, - encryption_algorithm: Union[str, "EncryptionAlgorithm"], + encryption_algorithm: Union[str, "_models.EncryptionAlgorithm"], encryption_cert_thumbprint: Optional[str] = None, **kwargs ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) + """ + :keyword value: The value of the secret. Required. + :paramtype value: str + :keyword encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :paramtype encryption_cert_thumbprint: str + :keyword encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values + are: "None", "AES256", and "RSAES_PKCS1_v_1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.EncryptionAlgorithm + """ + super().__init__(**kwargs) self.value = value self.encryption_cert_thumbprint = encryption_cert_thumbprint self.encryption_algorithm = encryption_algorithm -class Authentication(msrest.serialization.Model): +class Authentication(_serialization.Model): """Authentication mechanism for IoT devices. - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2019_08_01.models.SymmetricKey + :ivar symmetric_key: Symmetric key for authentication. + :vartype symmetric_key: ~azure.mgmt.databoxedge.v2019_08_01.models.SymmetricKey """ _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, + "symmetric_key": {"key": "symmetricKey", "type": "SymmetricKey"}, } - def __init__( - self, - *, - symmetric_key: Optional["SymmetricKey"] = None, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) + def __init__(self, *, symmetric_key: Optional["_models.SymmetricKey"] = None, **kwargs): + """ + :keyword symmetric_key: Symmetric key for authentication. + :paramtype symmetric_key: ~azure.mgmt.databoxedge.v2019_08_01.models.SymmetricKey + """ + super().__init__(**kwargs) self.symmetric_key = symmetric_key -class AzureContainerInfo(msrest.serialization.Model): +class AzureContainerInfo(_serialization.Model): """Azure container mapping of the endpoint. All required parameters must be populated in order to send to Azure. - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerDataFormat + :ivar storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :vartype storage_account_credential_id: str + :ivar container_name: Container name (Based on the data format specified, this represents the + name of Azure Files/Page blob/Block blob). Required. + :vartype container_name: str + :ivar data_format: Storage format used for the file represented by the share. Required. Known + values are: "BlockBlob", "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerDataFormat """ _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, + "storage_account_credential_id": {"required": True}, + "container_name": {"required": True}, + "data_format": {"required": True}, } _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, + "storage_account_credential_id": {"key": "storageAccountCredentialId", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "data_format": {"key": "dataFormat", "type": "str"}, } def __init__( @@ -338,10 +360,22 @@ def __init__( *, storage_account_credential_id: str, container_name: str, - data_format: Union[str, "AzureContainerDataFormat"], - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) + data_format: Union[str, "_models.AzureContainerDataFormat"], + **kwargs + ): + """ + :keyword storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :paramtype storage_account_credential_id: str + :keyword container_name: Container name (Based on the data format specified, this represents + the name of Azure Files/Page blob/Block blob). Required. + :paramtype container_name: str + :keyword data_format: Storage format used for the file represented by the share. Required. + Known values are: "BlockBlob", "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.storage_account_credential_id = storage_account_credential_id self.container_name = container_name self.data_format = data_format @@ -360,53 +394,57 @@ class BandwidthSchedule(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2019_08_01.models.DayOfWeek] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - *, - start: str, - stop: str, - rate_in_mbps: int, - days: List[Union[str, "DayOfWeek"]], - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) + :ivar start: The start time of the schedule in UTC. Required. + :vartype start: str + :ivar stop: The stop time of the schedule in UTC. Required. + :vartype stop: str + :ivar rate_in_mbps: The bandwidth rate in Mbps. Required. + :vartype rate_in_mbps: int + :ivar days: The days of the week when this schedule is applicable. Required. + :vartype days: list[str or ~azure.mgmt.databoxedge.v2019_08_01.models.DayOfWeek] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "start": {"required": True}, + "stop": {"required": True}, + "rate_in_mbps": {"required": True}, + "days": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "start": {"key": "properties.start", "type": "str"}, + "stop": {"key": "properties.stop", "type": "str"}, + "rate_in_mbps": {"key": "properties.rateInMbps", "type": "int"}, + "days": {"key": "properties.days", "type": "[str]"}, + } + + def __init__( + self, *, start: str, stop: str, rate_in_mbps: int, days: List[Union[str, "_models.DayOfWeek"]], **kwargs + ): + """ + :keyword start: The start time of the schedule in UTC. Required. + :paramtype start: str + :keyword stop: The stop time of the schedule in UTC. Required. + :paramtype stop: str + :keyword rate_in_mbps: The bandwidth rate in Mbps. Required. + :paramtype rate_in_mbps: int + :keyword days: The days of the week when this schedule is applicable. Required. + :paramtype days: list[str or ~azure.mgmt.databoxedge.v2019_08_01.models.DayOfWeek] + """ + super().__init__(**kwargs) self.start = start self.stop = stop self.rate_in_mbps = rate_in_mbps self.days = days -class BandwidthSchedulesList(msrest.serialization.Model): +class BandwidthSchedulesList(_serialization.Model): """The collection of bandwidth schedules. Variables are only populated by the server, and will be ignored when sending a request. @@ -418,75 +456,76 @@ class BandwidthSchedulesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BandwidthSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ClientAccessRight(msrest.serialization.Model): +class ClientAccessRight(_serialization.Model): """The mapping between a particular client IP and the type of access client has on the NFS share. All required parameters must be populated in order to send to Azure. - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ClientPermissionType + :ivar client: IP of the client. Required. + :vartype client: str + :ivar access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :vartype access_permission: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.ClientPermissionType """ _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, + "client": {"required": True}, + "access_permission": {"required": True}, } _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, + "client": {"key": "client", "type": "str"}, + "access_permission": {"key": "accessPermission", "type": "str"}, } - def __init__( - self, - *, - client: str, - access_permission: Union[str, "ClientPermissionType"], - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) + def __init__(self, *, client: str, access_permission: Union[str, "_models.ClientPermissionType"], **kwargs): + """ + :keyword client: IP of the client. Required. + :paramtype client: str + :keyword access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :paramtype access_permission: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.ClientPermissionType + """ + super().__init__(**kwargs) self.client = client self.access_permission = access_permission -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2019_08_01.models.CloudErrorBody] + :vartype message: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.databoxedge.v2019_08_01.models.CloudErrorBody] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -494,54 +533,66 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.databoxedge.v2019_08_01.models.CloudErrorBody] + """ + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class ContactDetails(msrest.serialization.Model): +class ContactDetails(_serialization.Model): """Contains all the contact details of the customer. All required parameters must be populated in order to send to Azure. - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] + :ivar contact_person: The contact person name. Required. + :vartype contact_person: str + :ivar company_name: The name of the company. Required. + :vartype company_name: str + :ivar phone: The phone number. Required. + :vartype phone: str + :ivar email_list: The email list. Required. + :vartype email_list: list[str] """ _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, + "contact_person": {"required": True}, + "company_name": {"required": True}, + "phone": {"required": True}, + "email_list": {"required": True}, } _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, + "contact_person": {"key": "contactPerson", "type": "str"}, + "company_name": {"key": "companyName", "type": "str"}, + "phone": {"key": "phone", "type": "str"}, + "email_list": {"key": "emailList", "type": "[str]"}, } - def __init__( - self, - *, - contact_person: str, - company_name: str, - phone: str, - email_list: List[str], - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) + def __init__(self, *, contact_person: str, company_name: str, phone: str, email_list: List[str], **kwargs): + """ + :keyword contact_person: The contact person name. Required. + :paramtype contact_person: str + :keyword company_name: The name of the company. Required. + :paramtype company_name: str + :keyword phone: The phone number. Required. + :paramtype phone: str + :keyword email_list: The email list. Required. + :paramtype email_list: list[str] + """ + super().__init__(**kwargs) self.contact_person = contact_person self.company_name = company_name self.phone = phone @@ -561,12 +612,13 @@ class Container(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". + :ivar container_status: Current status of the container. Known values are: "OK", "Offline", + "Unknown", "Updating", and "NeedsAttention". :vartype container_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerDataFormat + :ivar data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerDataFormat :ivar refresh_details: Details of the refresh job on this container. :vartype refresh_details: ~azure.mgmt.databoxedge.v2019_08_01.models.RefreshDetails :ivar created_date_time: The UTC time when container got created. @@ -574,39 +626,40 @@ class Container(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "container_status": {"readonly": True}, + "data_format": {"required": True}, + "refresh_details": {"readonly": True}, + "created_date_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "container_status": {"key": "properties.containerStatus", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, } - def __init__( - self, - *, - data_format: Union[str, "AzureContainerDataFormat"], - **kwargs - ): - super(Container, self).__init__(**kwargs) + def __init__(self, *, data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs): + """ + :keyword data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.container_status = None self.data_format = data_format self.refresh_details = None self.created_date_time = None -class ContainerList(msrest.serialization.Model): +class ContainerList(_serialization.Model): """Collection of all the containers on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -618,25 +671,23 @@ class ContainerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Container]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevice(ARMBaseModel): +class DataBoxEdgeDevice(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -649,34 +700,33 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure + :ivar location: The location of the device. This is a supported and registered Azure geographical region (for example, West US, East US, or Southeast Asia). The geographical region of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2019_08_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or + specified on update, the request will succeed. Required. + :vartype location: str + :ivar tags: The list of tags that describe the device. These tags can be used to view and group + this device (across resource groups). + :vartype tags: dict[str, str] + :ivar sku: The SKU type. + :vartype sku: ~azure.mgmt.databoxedge.v2019_08_01.models.Sku + :ivar etag: The etag for the devices. + :vartype etag: str + :ivar data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known values + are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :vartype data_box_edge_device_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDeviceStatus :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. :vartype serial_number: str - :param description: The Description of the Data Box Edge/Gateway device. - :type description: str - :param model_description: The description of the Data Box Edge/Gateway device model. - :type model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". + :ivar description: The Description of the Data Box Edge/Gateway device. + :vartype description: str + :ivar model_description: The description of the Data Box Edge/Gateway device model. + :vartype model_description: str + :ivar device_type: The type of the Data Box Edge/Gateway device. "DataBoxEdgeDevice" :vartype device_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DeviceType - :param friendly_name: The Data Box Edge/Gateway device name. - :type friendly_name: str + :ivar friendly_name: The Data Box Edge/Gateway device name. + :vartype friendly_name: str :ivar culture: The Data Box Edge/Gateway device culture. :vartype culture: str :ivar device_model: The Data Box Edge/Gateway device model. @@ -684,7 +734,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :ivar device_software_version: The Data Box Edge/Gateway device software version. :vartype device_software_version: str :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long + :vartype device_local_capacity: int :ivar time_zone: The Data Box Edge/Gateway device timezone. :vartype time_zone: str :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). @@ -697,44 +747,44 @@ class DataBoxEdgeDevice(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'serial_number': {'readonly': True}, - 'device_type': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "serial_number": {"readonly": True}, + "device_type": {"readonly": True}, + "culture": {"readonly": True}, + "device_model": {"readonly": True}, + "device_software_version": {"readonly": True}, + "device_local_capacity": {"readonly": True}, + "time_zone": {"readonly": True}, + "device_hcs_version": {"readonly": True}, + "configured_role_types": {"readonly": True}, + "node_count": {"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}"}, + "sku": {"key": "sku", "type": "Sku"}, + "etag": {"key": "etag", "type": "str"}, + "data_box_edge_device_status": {"key": "properties.dataBoxEdgeDeviceStatus", "type": "str"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "model_description": {"key": "properties.modelDescription", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "culture": {"key": "properties.culture", "type": "str"}, + "device_model": {"key": "properties.deviceModel", "type": "str"}, + "device_software_version": {"key": "properties.deviceSoftwareVersion", "type": "str"}, + "device_local_capacity": {"key": "properties.deviceLocalCapacity", "type": "int"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "device_hcs_version": {"key": "properties.deviceHcsVersion", "type": "str"}, + "configured_role_types": {"key": "properties.configuredRoleTypes", "type": "[str]"}, + "node_count": {"key": "properties.nodeCount", "type": "int"}, } def __init__( @@ -742,15 +792,40 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, etag: Optional[str] = None, - data_box_edge_device_status: Optional[Union[str, "DataBoxEdgeDeviceStatus"]] = None, + data_box_edge_device_status: Optional[Union[str, "_models.DataBoxEdgeDeviceStatus"]] = None, description: Optional[str] = None, model_description: Optional[str] = None, friendly_name: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) + """ + :keyword location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :paramtype location: str + :keyword tags: The list of tags that describe the device. These tags can be used to view and + group this device (across resource groups). + :paramtype tags: dict[str, str] + :keyword sku: The SKU type. + :paramtype sku: ~azure.mgmt.databoxedge.v2019_08_01.models.Sku + :keyword etag: The etag for the devices. + :paramtype etag: str + :keyword data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known + values are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :paramtype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDeviceStatus + :keyword description: The Description of the Data Box Edge/Gateway device. + :paramtype description: str + :keyword model_description: The description of the Data Box Edge/Gateway device model. + :paramtype model_description: str + :keyword friendly_name: The Data Box Edge/Gateway device name. + :paramtype friendly_name: str + """ + super().__init__(**kwargs) self.location = location self.tags = tags self.sku = sku @@ -782,45 +857,48 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to + :ivar encryption_key_thumbprint: The digital signature of encrypted certificate. + :vartype encryption_key_thumbprint: str + :ivar encryption_key: The public part of the encryption certificate. Client uses this to encrypt any secret. - :type encryption_key: str + :vartype encryption_key: str :ivar resource_key: The Resource ID of the Resource. :vartype resource_key: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_key": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encryption_key_thumbprint": {"key": "properties.encryptionKeyThumbprint", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "str"}, + "resource_key": {"key": "properties.resourceKey", "type": "str"}, } def __init__( - self, - *, - encryption_key_thumbprint: Optional[str] = None, - encryption_key: Optional[str] = None, - **kwargs + self, *, encryption_key_thumbprint: Optional[str] = None, encryption_key: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) + """ + :keyword encryption_key_thumbprint: The digital signature of encrypted certificate. + :paramtype encryption_key_thumbprint: str + :keyword encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :paramtype encryption_key: str + """ + super().__init__(**kwargs) self.encryption_key_thumbprint = encryption_key_thumbprint self.encryption_key = encryption_key self.resource_key = None -class DataBoxEdgeDeviceList(msrest.serialization.Model): +class DataBoxEdgeDeviceList(_serialization.Model): """The collection of Data Box Edge/Gateway devices. Variables are only populated by the server, and will be ignored when sending a request. @@ -832,50 +910,47 @@ class DataBoxEdgeDeviceList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevicePatch(msrest.serialization.Model): +class DataBoxEdgeDevicePatch(_serialization.Model): """The Data Box Edge/Gateway device patch. - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] + :ivar tags: The tags attached to the Data Box Edge/Gateway resource. + :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: The tags attached to the Data Box Edge/Gateway resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) self.tags = tags class Trigger(ARMBaseModel): """Trigger details. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FileEventTrigger, PeriodicTimerEventTrigger Variables are only populated by the server, and will be ignored when sending a request. @@ -887,35 +962,30 @@ class Trigger(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.TriggerEventType + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.TriggerEventType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } + _subtype_map = {"kind": {"FileEvent": "FileEventTrigger", "PeriodicTimerEvent": "PeriodicTimerEventTrigger"}} - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.kind = 'Trigger' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None class FileEventTrigger(Trigger): @@ -931,105 +1001,113 @@ class FileEventTrigger(Trigger): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2019_08_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2019_08_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.TriggerEventType + :ivar source_info: File event source details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2019_08_01.models.FileSourceInfo + :ivar sink_info: Role sink info. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2019_08_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "FileSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "FileSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.FileSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str + """ + :keyword source_info: File event source details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2019_08_01.models.FileSourceInfo + :keyword sink_info: Role sink info. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2019_08_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "FileEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class FileSourceInfo(msrest.serialization.Model): +class FileSourceInfo(_serialization.Model): """File source details. All required parameters must be populated in order to send to Azure. - :param share_id: Required. File share ID. - :type share_id: str + :ivar share_id: File share ID. Required. + :vartype share_id: str """ _validation = { - 'share_id': {'required': True}, + "share_id": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: File share ID. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id -class IoTDeviceInfo(msrest.serialization.Model): +class IoTDeviceInfo(_serialization.Model): """Metadata of IoT device/IoT Edge device to be configured. All required parameters must be populated in order to send to Azure. - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: IoT device authentication info. - :type authentication: ~azure.mgmt.databoxedge.v2019_08_01.models.Authentication + :ivar device_id: ID of the IoT device/edge device. Required. + :vartype device_id: str + :ivar io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :vartype io_t_host_hub: str + :ivar io_t_host_hub_id: Id for the IoT hub associated to the device. + :vartype io_t_host_hub_id: str + :ivar authentication: IoT device authentication info. + :vartype authentication: ~azure.mgmt.databoxedge.v2019_08_01.models.Authentication """ _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, + "device_id": {"required": True}, + "io_t_host_hub": {"required": True}, } _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, + "device_id": {"key": "deviceId", "type": "str"}, + "io_t_host_hub": {"key": "ioTHostHub", "type": "str"}, + "io_t_host_hub_id": {"key": "ioTHostHubId", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, } def __init__( @@ -1038,10 +1116,20 @@ def __init__( device_id: str, io_t_host_hub: str, io_t_host_hub_id: Optional[str] = None, - authentication: Optional["Authentication"] = None, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) + authentication: Optional["_models.Authentication"] = None, + **kwargs + ): + """ + :keyword device_id: ID of the IoT device/edge device. Required. + :paramtype device_id: str + :keyword io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :paramtype io_t_host_hub: str + :keyword io_t_host_hub_id: Id for the IoT hub associated to the device. + :paramtype io_t_host_hub_id: str + :keyword authentication: IoT device authentication info. + :paramtype authentication: ~azure.mgmt.databoxedge.v2019_08_01.models.Authentication + """ + super().__init__(**kwargs) self.device_id = device_id self.io_t_host_hub = io_t_host_hub self.io_t_host_hub_id = io_t_host_hub_id @@ -1051,8 +1139,8 @@ def __init__( class Role(ARMBaseModel): """Compute role. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: IoTRole. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + IoTRole Variables are only populated by the server, and will be ignored when sending a request. @@ -1064,35 +1152,30 @@ class Role(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", and "Cognitive". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleTypes """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'IOT': 'IoTRole'} - } + _subtype_map = {"kind": {"IOT": "IoTRole"}} - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None class IoTRole(Role): @@ -1108,54 +1191,68 @@ class IoTRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleTypes - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", and "Cognitive". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleTypes + :ivar host_platform: Host OS supported by the IoT role. Known values are: "Windows" and "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2019_08_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2019_08_01.models.PlatformType + :ivar io_t_device_details: IoT device metadata to which data box edge device needs to be connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2019_08_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_08_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2019_08_01.models.MountPointMap] - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleStatus + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2019_08_01.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_08_01.models.IoTDeviceInfo + :ivar share_mappings: Mount points of shares in role(s). + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2019_08_01.models.MountPointMap] + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - io_t_device_details: Optional["IoTDeviceInfo"] = None, - io_t_edge_device_details: Optional["IoTDeviceInfo"] = None, - share_mappings: Optional[List["MountPointMap"]] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + io_t_device_details: Optional["_models.IoTDeviceInfo"] = None, + io_t_edge_device_details: Optional["_models.IoTDeviceInfo"] = None, + share_mappings: Optional[List["_models.MountPointMap"]] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, + **kwargs + ): + """ + :keyword host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :paramtype host_platform: str or ~azure.mgmt.databoxedge.v2019_08_01.models.PlatformType + :keyword io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :paramtype io_t_device_details: ~azure.mgmt.databoxedge.v2019_08_01.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT role needs to be + configured. + :paramtype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2019_08_01.models.IoTDeviceInfo + :keyword share_mappings: Mount points of shares in role(s). + :paramtype share_mappings: list[~azure.mgmt.databoxedge.v2019_08_01.models.MountPointMap] + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "IOT" self.host_platform = host_platform self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details @@ -1163,7 +1260,7 @@ def __init__( self.role_status = role_status -class Ipv4Config(msrest.serialization.Model): +class Ipv4Config(_serialization.Model): """Details related to the IPv4 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1177,28 +1274,26 @@ class Ipv4Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "subnet": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.subnet = None self.gateway = None -class Ipv6Config(msrest.serialization.Model): +class Ipv6Config(_serialization.Model): """Details related to the IPv6 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1212,28 +1307,26 @@ class Ipv6Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "prefix_length": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "int"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.prefix_length = None self.gateway = None -class Job(msrest.serialization.Model): +class Job(_serialization.Model): # pylint: disable=too-many-instance-attributes """A device job. Variables are only populated by the server, and will be ignored when sending a request. @@ -1244,8 +1337,8 @@ class Job(msrest.serialization.Model): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar status: The current status of the job. Known values are: "Invalid", "Running", + "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.JobStatus :ivar start_time: The UTC date and time at which the job started. :vartype start_time: ~datetime.datetime @@ -1255,13 +1348,13 @@ class Job(msrest.serialization.Model): :vartype percent_complete: int :ivar error: The error details. :vartype error: ~azure.mgmt.databoxedge.v2019_08_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer". + :ivar job_type: The type of the job. Known values are: "Invalid", "ScanForUpdates", + "DownloadUpdates", "InstallUpdates", "RefreshShare", and "RefreshContainer". :vartype job_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", + :ivar current_stage: Current stage of the update operation. Known values are: "Unknown", "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". + "Success", "Failure", "RescanStarted", "RescanComplete", and "RescanFailed". :vartype current_stage: str or ~azure.mgmt.databoxedge.v2019_08_01.models.UpdateOperationStage :ivar download_progress: The download progress. :vartype download_progress: ~azure.mgmt.databoxedge.v2019_08_01.models.UpdateDownloadProgress @@ -1274,55 +1367,55 @@ class Job(msrest.serialization.Model): :vartype error_manifest_file: str :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - *, - folder: Optional[str] = None, - **kwargs - ): - super(Job, self).__init__(**kwargs) + :ivar folder: If only subfolders need to be refreshed, then the subfolder path inside the share + or container. (The path is empty if there are no subfolders.). + :vartype folder: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "error": {"readonly": True}, + "job_type": {"readonly": True}, + "current_stage": {"readonly": True}, + "download_progress": {"readonly": True}, + "install_progress": {"readonly": True}, + "total_refresh_errors": {"readonly": True}, + "error_manifest_file": {"readonly": True}, + "refreshed_entity_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "error": {"key": "error", "type": "JobErrorDetails"}, + "job_type": {"key": "properties.jobType", "type": "str"}, + "current_stage": {"key": "properties.currentStage", "type": "str"}, + "download_progress": {"key": "properties.downloadProgress", "type": "UpdateDownloadProgress"}, + "install_progress": {"key": "properties.installProgress", "type": "UpdateInstallProgress"}, + "total_refresh_errors": {"key": "properties.totalRefreshErrors", "type": "int"}, + "error_manifest_file": {"key": "properties.errorManifestFile", "type": "str"}, + "refreshed_entity_id": {"key": "properties.refreshedEntityId", "type": "str"}, + "folder": {"key": "properties.folder", "type": "str"}, + } + + def __init__(self, *, folder: Optional[str] = None, **kwargs): + """ + :keyword folder: If only subfolders need to be refreshed, then the subfolder path inside the + share or container. (The path is empty if there are no subfolders.). + :paramtype folder: str + """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1341,7 +1434,7 @@ def __init__( self.folder = folder -class JobErrorDetails(msrest.serialization.Model): +class JobErrorDetails(_serialization.Model): """The job error information containing the list of job errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -1355,28 +1448,26 @@ class JobErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "error_details": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "error_details": {"key": "errorDetails", "type": "[JobErrorItem]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_details = None self.code = None self.message = None -class JobErrorItem(msrest.serialization.Model): +class JobErrorItem(_serialization.Model): """The job error items. Variables are only populated by the server, and will be ignored when sending a request. @@ -1390,42 +1481,40 @@ class JobErrorItem(msrest.serialization.Model): """ _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "recommendations": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "recommendations": {"key": "recommendations", "type": "[str]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.recommendations = None self.code = None self.message = None -class MetricDimensionV1(msrest.serialization.Model): +class MetricDimensionV1(_serialization.Model): """Metric Dimension v1. - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the metrics dimension. + :vartype name: str + :ivar display_name: Display name of the metrics dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -1436,55 +1525,64 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(MetricDimensionV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metrics dimension. + :paramtype name: str + :keyword display_name: Display name of the metrics dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecificationV1(msrest.serialization.Model): +class MetricSpecificationV1(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric specification version 1. - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2019_08_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Description of the metric to be displayed. + :vartype display_description: str + :ivar unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :vartype unit: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricUnit + :ivar aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :vartype aggregation_type: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.MetricAggregationType + :ivar dimensions: Metric dimensions, other than default dimension which is resource. + :vartype dimensions: list[~azure.mgmt.databoxedge.v2019_08_01.models.MetricDimensionV1] + :ivar fill_gap_with_zero: Set true to fill the gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar category: Metric category. Known values are: "Capacity" and "Transaction". + :vartype category: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricCategory + :ivar resource_id_dimension_name_override: Resource name override. + :vartype resource_id_dimension_name_override: str + :ivar supported_time_grain_types: Support granularity of metrics. + :vartype supported_time_grain_types: list[str or ~azure.mgmt.databoxedge.v2019_08_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricAggregationType] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimensionV1]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, } def __init__( @@ -1493,17 +1591,46 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, display_description: Optional[str] = None, - unit: Optional[Union[str, "MetricUnit"]] = None, - aggregation_type: Optional[Union[str, "MetricAggregationType"]] = None, - dimensions: Optional[List["MetricDimensionV1"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, + dimensions: Optional[List["_models.MetricDimensionV1"]] = None, fill_gap_with_zero: Optional[bool] = None, - category: Optional[Union[str, "MetricCategory"]] = None, + category: Optional[Union[str, "_models.MetricCategory"]] = None, resource_id_dimension_name_override: Optional[str] = None, - supported_time_grain_types: Optional[List[Union[str, "TimeGrain"]]] = None, - supported_aggregation_types: Optional[List[Union[str, "MetricAggregationType"]]] = None, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) + supported_time_grain_types: Optional[List[Union[str, "_models.TimeGrain"]]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, + **kwargs + ): + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Description of the metric to be displayed. + :paramtype display_description: str + :keyword unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :paramtype unit: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricUnit + :keyword aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :paramtype aggregation_type: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.MetricAggregationType + :keyword dimensions: Metric dimensions, other than default dimension which is resource. + :paramtype dimensions: list[~azure.mgmt.databoxedge.v2019_08_01.models.MetricDimensionV1] + :keyword fill_gap_with_zero: Set true to fill the gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: Metric category. Known values are: "Capacity" and "Transaction". + :paramtype category: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MetricCategory + :keyword resource_id_dimension_name_override: Resource name override. + :paramtype resource_id_dimension_name_override: str + :keyword supported_time_grain_types: Support granularity of metrics. + :paramtype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2019_08_01.models.TimeGrain] + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2019_08_01.models.MetricAggregationType] + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1517,51 +1644,50 @@ def __init__( self.supported_aggregation_types = supported_aggregation_types -class MountPointMap(msrest.serialization.Model): +class MountPointMap(_serialization.Model): """The share mount point. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str + :ivar share_id: ID of the share mounted to the role VM. Required. + :vartype share_id: str :ivar role_id: ID of the role to which share is mounted. :vartype role_id: str :ivar mount_point: Mount point for the share. :vartype mount_point: str - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive". + :ivar role_type: Role type. Known values are: "IOT", "ASA", "Functions", and "Cognitive". :vartype role_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.RoleTypes """ _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'role_type': {'readonly': True}, + "share_id": {"required": True}, + "role_id": {"readonly": True}, + "mount_point": {"readonly": True}, + "role_type": {"readonly": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "mount_point": {"key": "mountPoint", "type": "str"}, + "role_type": {"key": "roleType", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: ID of the share mounted to the role VM. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id self.role_id = None self.mount_point = None self.role_type = None -class NetworkAdapter(msrest.serialization.Model): +class NetworkAdapter(_serialization.Model): # pylint: disable=too-many-instance-attributes """Represents the networkAdapter on a device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1581,16 +1707,18 @@ class NetworkAdapter(msrest.serialization.Model): :ivar mac_address: MAC address. :vartype mac_address: str :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". + :vartype link_speed: int + :ivar status: Value indicating whether this adapter is valid. Known values are: "Inactive" and + "Active". :vartype status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterDHCPStatus + :ivar rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :vartype rdma_status: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterRDMAStatus + :ivar dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :vartype dhcp_status: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterDHCPStatus :ivar ipv4_configuration: The IPv4 configuration of the network adapter. :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2019_08_01.models.Ipv4Config :ivar ipv6_configuration: The IPv6 configuration of the network adapter. @@ -1602,47 +1730,57 @@ class NetworkAdapter(msrest.serialization.Model): """ _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, + "adapter_id": {"readonly": True}, + "adapter_position": {"readonly": True}, + "index": {"readonly": True}, + "node_id": {"readonly": True}, + "network_adapter_name": {"readonly": True}, + "label": {"readonly": True}, + "mac_address": {"readonly": True}, + "link_speed": {"readonly": True}, + "status": {"readonly": True}, + "ipv4_configuration": {"readonly": True}, + "ipv6_configuration": {"readonly": True}, + "ipv6_link_local_address": {"readonly": True}, + "dns_servers": {"readonly": True}, + } + + _attribute_map = { + "adapter_id": {"key": "adapterId", "type": "str"}, + "adapter_position": {"key": "adapterPosition", "type": "NetworkAdapterPosition"}, + "index": {"key": "index", "type": "int"}, + "node_id": {"key": "nodeId", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "mac_address": {"key": "macAddress", "type": "str"}, + "link_speed": {"key": "linkSpeed", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "rdma_status": {"key": "rdmaStatus", "type": "str"}, + "dhcp_status": {"key": "dhcpStatus", "type": "str"}, + "ipv4_configuration": {"key": "ipv4Configuration", "type": "Ipv4Config"}, + "ipv6_configuration": {"key": "ipv6Configuration", "type": "Ipv6Config"}, + "ipv6_link_local_address": {"key": "ipv6LinkLocalAddress", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, } def __init__( self, *, - rdma_status: Optional[Union[str, "NetworkAdapterRDMAStatus"]] = None, - dhcp_status: Optional[Union[str, "NetworkAdapterDHCPStatus"]] = None, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) + rdma_status: Optional[Union[str, "_models.NetworkAdapterRDMAStatus"]] = None, + dhcp_status: Optional[Union[str, "_models.NetworkAdapterDHCPStatus"]] = None, + **kwargs + ): + """ + :keyword rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :paramtype rdma_status: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterRDMAStatus + :keyword dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :paramtype dhcp_status: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkAdapterDHCPStatus + """ + super().__init__(**kwargs) self.adapter_id = None self.adapter_position = None self.index = None @@ -1660,32 +1798,30 @@ def __init__( self.dns_servers = None -class NetworkAdapterPosition(msrest.serialization.Model): +class NetworkAdapterPosition(_serialization.Model): """The network adapter position. Variables are only populated by the server, and will be ignored when sending a request. - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". + :ivar network_group: The network group. Known values are: "None", "NonRDMA", and "RDMA". :vartype network_group: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkGroup :ivar port: The port. :vartype port: int """ _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, + "network_group": {"readonly": True}, + "port": {"readonly": True}, } _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, + "network_group": {"key": "networkGroup", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_group = None self.port = None @@ -1706,89 +1842,85 @@ class NetworkSettings(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "network_adapters": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "network_adapters": {"key": "properties.networkAdapters", "type": "[NetworkAdapter]"}, } - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_adapters = None class Node(ARMBaseModel): """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) + Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node + Multi-node Edge devices will have more than 1 nodes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar node_status: The current status of the individual node. Known values are: "Unknown", + "Up", "Down", "Rebooting", and "ShuttingDown". + :vartype node_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.NodeStatus + :ivar node_chassis_serial_number: Serial number of the Chassis. + :vartype node_chassis_serial_number: str + :ivar node_serial_number: Serial number of the individual node. + :vartype node_serial_number: str + :ivar node_display_name: Display Name of the individual node. + :vartype node_display_name: str + :ivar node_friendly_software_version: Friendly software version name that is currently + installed on the node. + :vartype node_friendly_software_version: str + :ivar node_hcs_version: HCS version that is currently installed on the node. + :vartype node_hcs_version: str + :ivar node_instance_id: Guid instance id of the node. + :vartype node_instance_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "node_status": {"readonly": True}, + "node_chassis_serial_number": {"readonly": True}, + "node_serial_number": {"readonly": True}, + "node_display_name": {"readonly": True}, + "node_friendly_software_version": {"readonly": True}, + "node_hcs_version": {"readonly": True}, + "node_instance_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "node_status": {"key": "properties.nodeStatus", "type": "str"}, + "node_chassis_serial_number": {"key": "properties.nodeChassisSerialNumber", "type": "str"}, + "node_serial_number": {"key": "properties.nodeSerialNumber", "type": "str"}, + "node_display_name": {"key": "properties.nodeDisplayName", "type": "str"}, + "node_friendly_software_version": {"key": "properties.nodeFriendlySoftwareVersion", "type": "str"}, + "node_hcs_version": {"key": "properties.nodeHcsVersion", "type": "str"}, + "node_instance_id": {"key": "properties.nodeInstanceId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.node_status = None self.node_chassis_serial_number = None self.node_serial_number = None @@ -1798,7 +1930,7 @@ def __init__( self.node_instance_id = None -class NodeList(msrest.serialization.Model): +class NodeList(_serialization.Model): """Collection of Nodes. Variables are only populated by the server, and will be ignored when sending a request. @@ -1808,75 +1940,84 @@ class NodeList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, + "value": {"key": "value", "type": "[Node]"}, } - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operations. - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2019_08_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2019_08_01.models.ServiceSpecification + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties displayed for the operation. + :vartype display: ~azure.mgmt.databoxedge.v2019_08_01.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar service_specification: Service specification. + :vartype service_specification: ~azure.mgmt.databoxedge.v2019_08_01.models.ServiceSpecification """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): - super(Operation, self).__init__(**kwargs) + service_specification: Optional["_models.ServiceSpecification"] = None, + **kwargs + ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties displayed for the operation. + :paramtype display: ~azure.mgmt.databoxedge.v2019_08_01.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword service_specification: Service specification. + :paramtype service_specification: + ~azure.mgmt.databoxedge.v2019_08_01.models.ServiceSpecification + """ + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display properties. - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: The type of resource in which the operation is performed. + :vartype resource: str + :ivar operation: Operation to be performed on the resource. + :vartype operation: str + :ivar description: Description of the operation to be performed. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1888,41 +2029,51 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: The type of resource in which the operation is performed. + :paramtype resource: str + :keyword operation: Operation to be performed on the resource. + :paramtype operation: str + :keyword description: Description of the operation to be performed. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsList(msrest.serialization.Model): +class OperationsList(_serialization.Model): """The list of operations used for the discovery of available provider operations. All required parameters must be populated in order to send to Azure. - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar value: The value. Required. + :vartype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Operation] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["Operation"], - next_link: Optional[str] = None, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The value. Required. + :paramtype value: list[~azure.mgmt.databoxedge.v2019_08_01.models.Operation] + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1938,12 +2089,12 @@ class Order(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2019_08_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2019_08_01.models.Address - :param current_status: Current status of the order. - :type current_status: ~azure.mgmt.databoxedge.v2019_08_01.models.OrderStatus + :ivar contact_information: The contact details. + :vartype contact_information: ~azure.mgmt.databoxedge.v2019_08_01.models.ContactDetails + :ivar shipping_address: The shipping address. + :vartype shipping_address: ~azure.mgmt.databoxedge.v2019_08_01.models.Address + :ivar current_status: Current status of the order. + :vartype current_status: ~azure.mgmt.databoxedge.v2019_08_01.models.OrderStatus :ivar order_history: List of status changes in the order. :vartype order_history: list[~azure.mgmt.databoxedge.v2019_08_01.models.OrderStatus] :ivar serial_number: Serial number of the device. @@ -1957,37 +2108,45 @@ class Order(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "order_history": {"readonly": True}, + "serial_number": {"readonly": True}, + "delivery_tracking_info": {"readonly": True}, + "return_tracking_info": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "contact_information": {"key": "properties.contactInformation", "type": "ContactDetails"}, + "shipping_address": {"key": "properties.shippingAddress", "type": "Address"}, + "current_status": {"key": "properties.currentStatus", "type": "OrderStatus"}, + "order_history": {"key": "properties.orderHistory", "type": "[OrderStatus]"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "delivery_tracking_info": {"key": "properties.deliveryTrackingInfo", "type": "[TrackingInfo]"}, + "return_tracking_info": {"key": "properties.returnTrackingInfo", "type": "[TrackingInfo]"}, } def __init__( self, *, - contact_information: Optional["ContactDetails"] = None, - shipping_address: Optional["Address"] = None, - current_status: Optional["OrderStatus"] = None, - **kwargs - ): - super(Order, self).__init__(**kwargs) + contact_information: Optional["_models.ContactDetails"] = None, + shipping_address: Optional["_models.Address"] = None, + current_status: Optional["_models.OrderStatus"] = None, + **kwargs + ): + """ + :keyword contact_information: The contact details. + :paramtype contact_information: ~azure.mgmt.databoxedge.v2019_08_01.models.ContactDetails + :keyword shipping_address: The shipping address. + :paramtype shipping_address: ~azure.mgmt.databoxedge.v2019_08_01.models.Address + :keyword current_status: Current status of the order. + :paramtype current_status: ~azure.mgmt.databoxedge.v2019_08_01.models.OrderStatus + """ + super().__init__(**kwargs) self.contact_information = contact_information self.shipping_address = shipping_address self.current_status = current_status @@ -1997,7 +2156,7 @@ def __init__( self.return_tracking_info = None -class OrderList(msrest.serialization.Model): +class OrderList(_serialization.Model): """List of order entities. Variables are only populated by the server, and will be ignored when sending a request. @@ -2009,66 +2168,67 @@ class OrderList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Order]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OrderStatus(msrest.serialization.Model): +class OrderStatus(_serialization.Model): """Represents a single status change. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft". - :type status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.OrderState + :ivar status: Status of the order as per the allowed status types. Required. Known values are: + "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", and "CollectedAtMicrosoft". + :vartype status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.OrderState :ivar update_date_time: Time of status update. :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str + :ivar comments: Comments related to this status change. + :vartype comments: str :ivar additional_order_details: Dictionary to hold generic information which is not stored by the already existing properties. :vartype additional_order_details: dict[str, str] """ _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'additional_order_details': {'readonly': True}, + "status": {"required": True}, + "update_date_time": {"readonly": True}, + "additional_order_details": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, + "status": {"key": "status", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + "comments": {"key": "comments", "type": "str"}, + "additional_order_details": {"key": "additionalOrderDetails", "type": "{str}"}, } - def __init__( - self, - *, - status: Union[str, "OrderState"], - comments: Optional[str] = None, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) + def __init__(self, *, status: Union[str, "_models.OrderState"], comments: Optional[str] = None, **kwargs): + """ + :keyword status: Status of the order as per the allowed status types. Required. Known values + are: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", and "CollectedAtMicrosoft". + :paramtype status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.OrderState + :keyword comments: Comments related to this status change. + :paramtype comments: str + """ + super().__init__(**kwargs) self.status = status self.update_date_time = None self.comments = comments @@ -2088,119 +2248,132 @@ class PeriodicTimerEventTrigger(Trigger): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2019_08_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2019_08_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2019_08_01.models.TriggerEventType + :ivar source_info: Periodic timer details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2019_08_01.models.PeriodicTimerSourceInfo + :ivar sink_info: Role Sink information. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2019_08_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "PeriodicTimerSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "PeriodicTimerSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.PeriodicTimerSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str + """ + :keyword source_info: Periodic timer details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2019_08_01.models.PeriodicTimerSourceInfo + :keyword sink_info: Role Sink information. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2019_08_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "PeriodicTimerEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class PeriodicTimerSourceInfo(msrest.serialization.Model): +class PeriodicTimerSourceInfo(_serialization.Model): """Periodic timer event source. All required parameters must be populated in order to send to Azure. - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str + :ivar start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :vartype start_time: ~datetime.datetime + :ivar schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :vartype schedule: str + :ivar topic: Topic where periodic events are published to IoT device. + :vartype topic: str """ _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, + "start_time": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "schedule": {"key": "schedule", "type": "str"}, + "topic": {"key": "topic", "type": "str"}, } - def __init__( - self, - *, - start_time: datetime.datetime, - schedule: str, - topic: Optional[str] = None, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) + def __init__(self, *, start_time: datetime.datetime, schedule: str, topic: Optional[str] = None, **kwargs): + """ + :keyword start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :paramtype start_time: ~datetime.datetime + :keyword schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :paramtype schedule: str + :keyword topic: Topic where periodic events are published to IoT device. + :paramtype topic: str + """ + super().__init__(**kwargs) self.start_time = start_time self.schedule = schedule self.topic = topic -class RefreshDetails(msrest.serialization.Model): +class RefreshDetails(_serialization.Model): """Fields for tracking refresh job on the share or container. - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + :ivar in_progress_refresh_job_id: If a refresh job is currently in progress on this share or container, this field indicates the ARM resource ID of that job. The field is empty if no job is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh + :vartype in_progress_refresh_job_id: str + :ivar last_completed_refresh_job_time_in_utc: Indicates the completed time for the last refresh + job on this particular share or container, if any.This could be a failed job or a successful + job. + :vartype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :ivar error_manifest_file: Indicates the relative path of the error xml for the last refresh job on this particular share or container, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or + :vartype error_manifest_file: str + :ivar last_job: Indicates the id of the last refresh job on this particular share or container,if any. This could be a failed job or a successful job. - :type last_job: str + :vartype last_job: str """ _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, + "in_progress_refresh_job_id": {"key": "inProgressRefreshJobId", "type": "str"}, + "last_completed_refresh_job_time_in_utc": {"key": "lastCompletedRefreshJobTimeInUTC", "type": "iso-8601"}, + "error_manifest_file": {"key": "errorManifestFile", "type": "str"}, + "last_job": {"key": "lastJob", "type": "str"}, } def __init__( @@ -2212,27 +2385,44 @@ def __init__( last_job: Optional[str] = None, **kwargs ): - super(RefreshDetails, self).__init__(**kwargs) + """ + :keyword in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + container, this field indicates the ARM resource ID of that job. The field is empty if no job + is in progress. + :paramtype in_progress_refresh_job_id: str + :keyword last_completed_refresh_job_time_in_utc: Indicates the completed time for the last + refresh job on this particular share or container, if any.This could be a failed job or a + successful job. + :paramtype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :keyword error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share or container, if any. This could be a failed job or a successful + job. + :paramtype error_manifest_file: str + :keyword last_job: Indicates the id of the last refresh job on this particular share or + container,if any. This could be a failed job or a successful job. + :paramtype last_job: str + """ + super().__init__(**kwargs) self.in_progress_refresh_job_id = in_progress_refresh_job_id self.last_completed_refresh_job_time_in_utc = last_completed_refresh_job_time_in_utc self.error_manifest_file = error_manifest_file self.last_job = last_job -class ResourceTypeSku(msrest.serialization.Model): +class ResourceTypeSku(_serialization.Model): """SkuInformation object. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA". + :ivar name: The Sku name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", and + "TMA". :vartype name: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuName :ivar kind: The Sku kind. :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". + :ivar tier: The Sku tier. "Standard" :vartype tier: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuTier :ivar family: The Sku family. :vartype family: str @@ -2249,36 +2439,34 @@ class ResourceTypeSku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'restrictions': {'readonly': True}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "kind": {"readonly": True}, + "tier": {"readonly": True}, + "family": {"readonly": True}, + "locations": {"readonly": True}, + "api_versions": {"readonly": True}, + "location_info": {"readonly": True}, + "costs": {"readonly": True}, + "restrictions": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'restrictions': {'key': 'restrictions', 'type': '[SkuRestriction]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "restrictions": {"key": "restrictions", "type": "[SkuRestriction]"}, } - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.kind = None @@ -2291,7 +2479,7 @@ def __init__( self.restrictions = None -class RoleList(msrest.serialization.Model): +class RoleList(_serialization.Model): """Collection of all the roles on the Data Box Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2303,48 +2491,45 @@ class RoleList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Role]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RoleSinkInfo(msrest.serialization.Model): +class RoleSinkInfo(_serialization.Model): """Compute role against which events will be raised. All required parameters must be populated in order to send to Azure. - :param role_id: Required. Compute role ID. - :type role_id: str + :ivar role_id: Compute role ID. Required. + :vartype role_id: str """ _validation = { - 'role_id': {'required': True}, + "role_id": {"required": True}, } _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, + "role_id": {"key": "roleId", "type": "str"}, } - def __init__( - self, - *, - role_id: str, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) + def __init__(self, *, role_id: str, **kwargs): + """ + :keyword role_id: Compute role ID. Required. + :paramtype role_id: str + """ + super().__init__(**kwargs) self.role_id = role_id @@ -2361,61 +2546,64 @@ class SecuritySettings(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: + :ivar device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :vartype device_admin_password: ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "device_admin_password": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_admin_password": {"key": "properties.deviceAdminPassword", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - device_admin_password: "AsymmetricEncryptedSecret", - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) + def __init__(self, *, device_admin_password: "_models.AsymmetricEncryptedSecret", **kwargs): + """ + :keyword device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :paramtype device_admin_password: + ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.device_admin_password = device_admin_password -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification. - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: + :ivar metric_specifications: Metric specification as defined by shoebox. + :vartype metric_specifications: list[~azure.mgmt.databoxedge.v2019_08_01.models.MetricSpecificationV1] """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecificationV1]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["MetricSpecificationV1"]] = None, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecificationV1"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specification as defined by shoebox. + :paramtype metric_specifications: + list[~azure.mgmt.databoxedge.v2019_08_01.models.MetricSpecificationV1] + """ + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Share(ARMBaseModel): +class Share(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Represents a share on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2428,74 +2616,103 @@ class Share(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share + :ivar description: Description for the share. + :vartype description: str + :ivar share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :vartype share_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareStatus + :ivar monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :vartype monitoring_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.MonitoringStatus + :ivar azure_container_info: Azure container mapping for the share. + :vartype azure_container_info: ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerInfo + :ivar access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :vartype access_protocol: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessProtocol + :ivar user_access_rights: Mapping of users and corresponding access rights on the share (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2019_08_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the + :vartype user_access_rights: list[~azure.mgmt.databoxedge.v2019_08_01.models.UserAccessRight] + :ivar client_access_rights: List of IP addresses and corresponding access rights on the share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2019_08_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2019_08_01.models.RefreshDetails + :vartype client_access_rights: + list[~azure.mgmt.databoxedge.v2019_08_01.models.ClientAccessRight] + :ivar refresh_details: Details of the refresh job on this share. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2019_08_01.models.RefreshDetails :ivar share_mappings: Share mount point to the role. :vartype share_mappings: list[~azure.mgmt.databoxedge.v2019_08_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DataPolicy + :ivar data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DataPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "share_status": {"required": True}, + "monitoring_status": {"required": True}, + "access_protocol": {"required": True}, + "share_mappings": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "share_status": {"key": "properties.shareStatus", "type": "str"}, + "monitoring_status": {"key": "properties.monitoringStatus", "type": "str"}, + "azure_container_info": {"key": "properties.azureContainerInfo", "type": "AzureContainerInfo"}, + "access_protocol": {"key": "properties.accessProtocol", "type": "str"}, + "user_access_rights": {"key": "properties.userAccessRights", "type": "[UserAccessRight]"}, + "client_access_rights": {"key": "properties.clientAccessRights", "type": "[ClientAccessRight]"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, } def __init__( self, *, - share_status: Union[str, "ShareStatus"], - monitoring_status: Union[str, "MonitoringStatus"], - access_protocol: Union[str, "ShareAccessProtocol"], + share_status: Union[str, "_models.ShareStatus"], + monitoring_status: Union[str, "_models.MonitoringStatus"], + access_protocol: Union[str, "_models.ShareAccessProtocol"], description: Optional[str] = None, - azure_container_info: Optional["AzureContainerInfo"] = None, - user_access_rights: Optional[List["UserAccessRight"]] = None, - client_access_rights: Optional[List["ClientAccessRight"]] = None, - refresh_details: Optional["RefreshDetails"] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, - **kwargs - ): - super(Share, self).__init__(**kwargs) + azure_container_info: Optional["_models.AzureContainerInfo"] = None, + user_access_rights: Optional[List["_models.UserAccessRight"]] = None, + client_access_rights: Optional[List["_models.ClientAccessRight"]] = None, + refresh_details: Optional["_models.RefreshDetails"] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, + **kwargs + ): + """ + :keyword description: Description for the share. + :paramtype description: str + :keyword share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :paramtype share_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareStatus + :keyword monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :paramtype monitoring_status: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.MonitoringStatus + :keyword azure_container_info: Azure container mapping for the share. + :paramtype azure_container_info: ~azure.mgmt.databoxedge.v2019_08_01.models.AzureContainerInfo + :keyword access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :paramtype access_protocol: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessProtocol + :keyword user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :paramtype user_access_rights: list[~azure.mgmt.databoxedge.v2019_08_01.models.UserAccessRight] + :keyword client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :paramtype client_access_rights: + list[~azure.mgmt.databoxedge.v2019_08_01.models.ClientAccessRight] + :keyword refresh_details: Details of the refresh job on this share. + :paramtype refresh_details: ~azure.mgmt.databoxedge.v2019_08_01.models.RefreshDetails + :keyword data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DataPolicy + """ + super().__init__(**kwargs) self.description = description self.share_status = share_status self.monitoring_status = monitoring_status @@ -2508,41 +2725,42 @@ def __init__( self.data_policy = data_policy -class ShareAccessRight(msrest.serialization.Model): +class ShareAccessRight(_serialization.Model): """Specifies the mapping between this particular user and the type of access he has on shares on this device. All required parameters must be populated in order to send to Azure. - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessType + :ivar share_id: The share ID. Required. + :vartype share_id: str + :ivar access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessType """ _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, + "share_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) + def __init__(self, *, share_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword share_id: The share ID. Required. + :paramtype share_id: str + :keyword access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.share_id = share_id self.access_type = access_type -class ShareList(msrest.serialization.Model): +class ShareList(_serialization.Model): """Collection of all the shares on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2554,53 +2772,59 @@ class ShareList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Share]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU type. - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA". - :type name: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuTier + :ivar name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", and + "TMA". + :vartype name: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuTier """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "SkuName"]] = None, - tier: Optional[Union[str, "SkuTier"]] = None, - **kwargs - ): - super(Sku, self).__init__(**kwargs) + name: Optional[Union[str, "_models.SkuName"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, + **kwargs + ): + """ + :keyword name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", and + "TMA". + :paramtype name: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuName + :keyword tier: The SKU tier. This is based on the SKU name. "Standard" + :paramtype tier: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuTier + """ + super().__init__(**kwargs) self.name = name self.tier = tier -class SkuCost(msrest.serialization.Model): +class SkuCost(_serialization.Model): """The metadata for retrieving price info. Variables are only populated by the server, and will be ignored when sending a request. @@ -2608,34 +2832,32 @@ class SkuCost(msrest.serialization.Model): :ivar meter_id: Used for querying price from commerce. :vartype meter_id: str :ivar quantity: The cost quantity. - :vartype quantity: long + :vartype quantity: int :ivar extended_unit: Restriction of the SKU for the location/zone. :vartype extended_unit: str """ _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, + "meter_id": {"readonly": True}, + "quantity": {"readonly": True}, + "extended_unit": {"readonly": True}, } _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, + "meter_id": {"key": "meterId", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.meter_id = None self.quantity = None self.extended_unit = None -class SkuInformationList(msrest.serialization.Model): +class SkuInformationList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -2647,25 +2869,23 @@ class SkuInformationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceTypeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SkuLocationInfo(msrest.serialization.Model): +class SkuLocationInfo(_serialization.Model): """The location info. Variables are only populated by the server, and will be ignored when sending a request. @@ -2679,28 +2899,26 @@ class SkuLocationInfo(msrest.serialization.Model): """ _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, + "location": {"readonly": True}, + "zones": {"readonly": True}, + "sites": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "sites": {"key": "sites", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.zones = None self.sites = None -class SkuRestriction(msrest.serialization.Model): +class SkuRestriction(_serialization.Model): """The restrictions because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -2709,8 +2927,8 @@ class SkuRestriction(msrest.serialization.Model): :vartype type: str :ivar values: The locations where sku is restricted. :vartype values: list[str] - :ivar reason_code: The SKU restriction reason. Possible values include: - "NotAvailableForSubscription", "QuotaId". + :ivar reason_code: The SKU restriction reason. Known values are: "NotAvailableForSubscription" + and "QuotaId". :vartype reason_code: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SkuRestrictionReasonCode :ivar restriction_info: Restriction of the SKU for the location/zone. @@ -2718,31 +2936,29 @@ class SkuRestriction(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, - 'reason_code': {'readonly': True}, - 'restriction_info': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, + "reason_code": {"readonly": True}, + "restriction_info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'SkuRestrictionInfo'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, + "restriction_info": {"key": "restrictionInfo", "type": "SkuRestrictionInfo"}, } - def __init__( - self, - **kwargs - ): - super(SkuRestriction, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = None self.restriction_info = None -class SkuRestrictionInfo(msrest.serialization.Model): +class SkuRestrictionInfo(_serialization.Model): """The restriction info with locations and zones. Variables are only populated by the server, and will be ignored when sending a request. @@ -2754,20 +2970,18 @@ class SkuRestrictionInfo(msrest.serialization.Model): """ _validation = { - 'locations': {'readonly': True}, - 'zones': {'readonly': True}, + "locations": {"readonly": True}, + "zones": {"readonly": True}, } _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - super(SkuRestrictionInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.locations = None self.zones = None @@ -2783,17 +2997,16 @@ class StorageAccount(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or + :ivar description: Description for the storage Account. + :vartype description: str + :ivar storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :vartype storage_account_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountStatus - :param data_policy: Data policy of the storage Account. Possible values include: "Cloud", - "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str + :ivar data_policy: Data policy of the storage Account. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DataPolicy + :ivar storage_account_credential_id: Storage Account Credential Id. + :vartype storage_account_credential_id: str :ivar blob_endpoint: BlobEndpoint of Storage Account. :vartype blob_endpoint: str :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy @@ -2802,35 +3015,48 @@ class StorageAccount(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "blob_endpoint": {"readonly": True}, + "container_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "storage_account_status": {"key": "properties.storageAccountStatus", "type": "str"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, + "storage_account_credential_id": {"key": "properties.storageAccountCredentialId", "type": "str"}, + "blob_endpoint": {"key": "properties.blobEndpoint", "type": "str"}, + "container_count": {"key": "properties.containerCount", "type": "int"}, } def __init__( self, *, description: Optional[str] = None, - storage_account_status: Optional[Union[str, "StorageAccountStatus"]] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, + storage_account_status: Optional[Union[str, "_models.StorageAccountStatus"]] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, storage_account_credential_id: Optional[str] = None, **kwargs ): - super(StorageAccount, self).__init__(**kwargs) + """ + :keyword description: Description for the storage Account. + :paramtype description: str + :keyword storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :paramtype storage_account_status: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountStatus + :keyword data_policy: Data policy of the storage Account. Known values are: "Cloud" and + "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DataPolicy + :keyword storage_account_credential_id: Storage Account Credential Id. + :paramtype storage_account_credential_id: str + """ + super().__init__(**kwargs) self.description = description self.storage_account_status = storage_account_status self.data_policy = data_policy @@ -2839,7 +3065,7 @@ def __init__( self.container_count = None -class StorageAccountCredential(ARMBaseModel): +class StorageAccountCredential(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The storage account credential. Variables are only populated by the server, and will be ignored when sending a request. @@ -2852,64 +3078,85 @@ class StorageAccountCredential(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + :ivar alias: Alias for the storage account. Required. + :vartype alias: str + :ivar user_name: Username for the storage account. + :vartype user_name: str + :ivar account_key: Encrypted storage key. + :vartype account_key: ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string for the storage account. Use this string if username + and account key are not specified. + :vartype connection_string: str + :ivar ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values are: + "Enabled" and "Disabled". + :vartype ssl_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SSLStatus + :ivar blob_domain_name: Blob end point for private clouds. + :vartype blob_domain_name: str + :ivar account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :vartype account_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AccountType + :ivar storage_account_id: Id of the storage account. + :vartype storage_account_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "alias": {"required": True}, + "ssl_status": {"required": True}, + "account_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "alias": {"key": "properties.alias", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "account_key": {"key": "properties.accountKey", "type": "AsymmetricEncryptedSecret"}, + "connection_string": {"key": "properties.connectionString", "type": "str"}, + "ssl_status": {"key": "properties.sslStatus", "type": "str"}, + "blob_domain_name": {"key": "properties.blobDomainName", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, } def __init__( self, *, alias: str, - ssl_status: Union[str, "SSLStatus"], - account_type: Union[str, "AccountType"], + ssl_status: Union[str, "_models.SSLStatus"], + account_type: Union[str, "_models.AccountType"], user_name: Optional[str] = None, - account_key: Optional["AsymmetricEncryptedSecret"] = None, + account_key: Optional["_models.AsymmetricEncryptedSecret"] = None, connection_string: Optional[str] = None, blob_domain_name: Optional[str] = None, storage_account_id: Optional[str] = None, **kwargs ): - super(StorageAccountCredential, self).__init__(**kwargs) + """ + :keyword alias: Alias for the storage account. Required. + :paramtype alias: str + :keyword user_name: Username for the storage account. + :paramtype user_name: str + :keyword account_key: Encrypted storage key. + :paramtype account_key: ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret + :keyword connection_string: Connection string for the storage account. Use this string if + username and account key are not specified. + :paramtype connection_string: str + :keyword ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values + are: "Enabled" and "Disabled". + :paramtype ssl_status: str or ~azure.mgmt.databoxedge.v2019_08_01.models.SSLStatus + :keyword blob_domain_name: Blob end point for private clouds. + :paramtype blob_domain_name: str + :keyword account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :paramtype account_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AccountType + :keyword storage_account_id: Id of the storage account. + :paramtype storage_account_id: str + """ + super().__init__(**kwargs) self.alias = alias self.user_name = user_name self.account_key = account_key @@ -2920,7 +3167,7 @@ def __init__( self.storage_account_id = storage_account_id -class StorageAccountCredentialList(msrest.serialization.Model): +class StorageAccountCredentialList(_serialization.Model): """The collection of storage account credentials. Variables are only populated by the server, and will be ignored when sending a request. @@ -2932,25 +3179,23 @@ class StorageAccountCredentialList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccountCredential]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountList(msrest.serialization.Model): +class StorageAccountList(_serialization.Model): """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2962,63 +3207,62 @@ class StorageAccountList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SymmetricKey(msrest.serialization.Model): +class SymmetricKey(_serialization.Model): """Symmetric key for authentication. - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string based on the symmetric key. + :vartype connection_string: + ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret """ _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, + "connection_string": {"key": "connectionString", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) + def __init__(self, *, connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs): + """ + :keyword connection_string: Connection string based on the symmetric key. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.connection_string = connection_string -class TrackingInfo(msrest.serialization.Model): +class TrackingInfo(_serialization.Model): """Tracking courier information. - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str + :ivar serial_number: Serial number of the device being tracked. + :vartype serial_number: str + :ivar carrier_name: Name of the carrier used in the delivery. + :vartype carrier_name: str + :ivar tracking_id: Tracking ID of the shipment. + :vartype tracking_id: str + :ivar tracking_url: Tracking URL of the shipment. + :vartype tracking_url: str """ _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, + "serial_number": {"key": "serialNumber", "type": "str"}, + "carrier_name": {"key": "carrierName", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "tracking_url": {"key": "trackingUrl", "type": "str"}, } def __init__( @@ -3030,14 +3274,24 @@ def __init__( tracking_url: Optional[str] = None, **kwargs ): - super(TrackingInfo, self).__init__(**kwargs) + """ + :keyword serial_number: Serial number of the device being tracked. + :paramtype serial_number: str + :keyword carrier_name: Name of the carrier used in the delivery. + :paramtype carrier_name: str + :keyword tracking_id: Tracking ID of the shipment. + :paramtype tracking_id: str + :keyword tracking_url: Tracking URL of the shipment. + :paramtype tracking_url: str + """ + super().__init__(**kwargs) self.serial_number = serial_number self.carrier_name = carrier_name self.tracking_id = tracking_id self.tracking_url = tracking_url -class TriggerList(msrest.serialization.Model): +class TriggerList(_serialization.Model): """Collection of all trigger on the data box edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -3049,31 +3303,29 @@ class TriggerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Trigger]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class UpdateDownloadProgress(msrest.serialization.Model): +class UpdateDownloadProgress(_serialization.Model): """Details about the download progress of update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". + :ivar download_phase: The download phase. Known values are: "Unknown", "Initializing", + "Downloading", and "Verifying". :vartype download_phase: str or ~azure.mgmt.databoxedge.v2019_08_01.models.DownloadPhase :ivar percent_complete: Percentage of completion. :vartype percent_complete: int @@ -3088,28 +3340,26 @@ class UpdateDownloadProgress(msrest.serialization.Model): """ _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, + "download_phase": {"readonly": True}, + "percent_complete": {"readonly": True}, + "total_bytes_to_download": {"readonly": True}, + "total_bytes_downloaded": {"readonly": True}, + "number_of_updates_to_download": {"readonly": True}, + "number_of_updates_downloaded": {"readonly": True}, } _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, + "download_phase": {"key": "downloadPhase", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "total_bytes_to_download": {"key": "totalBytesToDownload", "type": "float"}, + "total_bytes_downloaded": {"key": "totalBytesDownloaded", "type": "float"}, + "number_of_updates_to_download": {"key": "numberOfUpdatesToDownload", "type": "int"}, + "number_of_updates_downloaded": {"key": "numberOfUpdatesDownloaded", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.download_phase = None self.percent_complete = None self.total_bytes_to_download = None @@ -3118,7 +3368,7 @@ def __init__( self.number_of_updates_downloaded = None -class UpdateInstallProgress(msrest.serialization.Model): +class UpdateInstallProgress(_serialization.Model): """Progress details during installation of updates. Variables are only populated by the server, and will be ignored when sending a request. @@ -3132,28 +3382,26 @@ class UpdateInstallProgress(msrest.serialization.Model): """ _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, + "percent_complete": {"readonly": True}, + "number_of_updates_to_install": {"readonly": True}, + "number_of_updates_installed": {"readonly": True}, } _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "number_of_updates_to_install": {"key": "numberOfUpdatesToInstall", "type": "int"}, + "number_of_updates_installed": {"key": "numberOfUpdatesInstalled", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.percent_complete = None self.number_of_updates_to_install = None self.number_of_updates_installed = None -class UpdateSummary(ARMBaseModel): +class UpdateSummary(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Details about ongoing updates and availability of updates on the device. Variables are only populated by the server, and will be ignored when sending a request. @@ -3164,15 +3412,15 @@ class UpdateSummary(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed + :ivar device_version_number: The current version of the device in format: 1.2.17312.13.",. + :vartype device_version_number: str + :ivar friendly_device_version_name: The current version of the device in text format. + :vartype friendly_device_version_name: str + :ivar device_last_scanned_date_time: The last time when a scan was done on the device. + :vartype device_last_scanned_date_time: ~datetime.datetime + :ivar last_completed_scan_job_date_time: The time when the last scan job was completed (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime + :vartype last_completed_scan_job_date_time: ~datetime.datetime :ivar last_completed_download_job_date_time: The time when the last Download job was completed (success/cancelled/failed) on the appliance. :vartype last_completed_download_job_date_time: ~datetime.datetime @@ -3187,11 +3435,11 @@ class UpdateSummary(ARMBaseModel): :ivar total_number_of_updates_pending_install: The total number of items pending install. :vartype total_number_of_updates_pending_install: int :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.databoxedge.v2019_08_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". + :ivar ongoing_update_operation: The current update operation. Known values are: "None", "Scan", + "Download", and "Install". :vartype ongoing_update_operation: str or ~azure.mgmt.databoxedge.v2019_08_01.models.UpdateOperation :ivar in_progress_download_job_id: The job ID of the download job in progress. @@ -3211,45 +3459,63 @@ class UpdateSummary(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_completed_download_job_date_time": {"readonly": True}, + "last_completed_install_job_date_time": {"readonly": True}, + "total_number_of_updates_available": {"readonly": True}, + "total_number_of_updates_pending_download": {"readonly": True}, + "total_number_of_updates_pending_install": {"readonly": True}, + "reboot_behavior": {"readonly": True}, + "ongoing_update_operation": {"readonly": True}, + "in_progress_download_job_id": {"readonly": True}, + "in_progress_install_job_id": {"readonly": True}, + "in_progress_download_job_started_date_time": {"readonly": True}, + "in_progress_install_job_started_date_time": {"readonly": True}, + "update_titles": {"readonly": True}, + "total_update_size_in_bytes": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_version_number": {"key": "properties.deviceVersionNumber", "type": "str"}, + "friendly_device_version_name": {"key": "properties.friendlyDeviceVersionName", "type": "str"}, + "device_last_scanned_date_time": {"key": "properties.deviceLastScannedDateTime", "type": "iso-8601"}, + "last_completed_scan_job_date_time": {"key": "properties.lastCompletedScanJobDateTime", "type": "iso-8601"}, + "last_completed_download_job_date_time": { + "key": "properties.lastCompletedDownloadJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_date_time": { + "key": "properties.lastCompletedInstallJobDateTime", + "type": "iso-8601", + }, + "total_number_of_updates_available": {"key": "properties.totalNumberOfUpdatesAvailable", "type": "int"}, + "total_number_of_updates_pending_download": { + "key": "properties.totalNumberOfUpdatesPendingDownload", + "type": "int", + }, + "total_number_of_updates_pending_install": { + "key": "properties.totalNumberOfUpdatesPendingInstall", + "type": "int", + }, + "reboot_behavior": {"key": "properties.rebootBehavior", "type": "str"}, + "ongoing_update_operation": {"key": "properties.ongoingUpdateOperation", "type": "str"}, + "in_progress_download_job_id": {"key": "properties.inProgressDownloadJobId", "type": "str"}, + "in_progress_install_job_id": {"key": "properties.inProgressInstallJobId", "type": "str"}, + "in_progress_download_job_started_date_time": { + "key": "properties.inProgressDownloadJobStartedDateTime", + "type": "iso-8601", + }, + "in_progress_install_job_started_date_time": { + "key": "properties.inProgressInstallJobStartedDateTime", + "type": "iso-8601", + }, + "update_titles": {"key": "properties.updateTitles", "type": "[str]"}, + "total_update_size_in_bytes": {"key": "properties.totalUpdateSizeInBytes", "type": "float"}, } def __init__( @@ -3261,7 +3527,18 @@ def __init__( last_completed_scan_job_date_time: Optional[datetime.datetime] = None, **kwargs ): - super(UpdateSummary, self).__init__(**kwargs) + """ + :keyword device_version_number: The current version of the device in format: 1.2.17312.13.",. + :paramtype device_version_number: str + :keyword friendly_device_version_name: The current version of the device in text format. + :paramtype friendly_device_version_name: str + :keyword device_last_scanned_date_time: The last time when a scan was done on the device. + :paramtype device_last_scanned_date_time: ~datetime.datetime + :keyword last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :paramtype last_completed_scan_job_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.device_version_number = device_version_number self.friendly_device_version_name = friendly_device_version_name self.device_last_scanned_date_time = device_last_scanned_date_time @@ -3281,47 +3558,56 @@ def __init__( self.total_update_size_in_bytes = None -class UploadCertificateRequest(msrest.serialization.Model): +class UploadCertificateRequest(_serialization.Model): """The upload certificate request. All required parameters must be populated in order to send to Azure. - :param authentication_type: The authentication type. Possible values include: "Invalid", + :ivar authentication_type: The authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str + :vartype authentication_type: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.AuthenticationType + :ivar certificate: The base64 encoded certificate raw data. Required. + :vartype certificate: str """ _validation = { - 'certificate': {'required': True}, + "certificate": {"required": True}, } _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "certificate": {"key": "properties.certificate", "type": "str"}, } def __init__( self, *, certificate: str, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + **kwargs + ): + """ + :keyword authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype authentication_type: str or + ~azure.mgmt.databoxedge.v2019_08_01.models.AuthenticationType + :keyword certificate: The base64 encoded certificate raw data. Required. + :paramtype certificate: str + """ + super().__init__(**kwargs) self.authentication_type = authentication_type self.certificate = certificate -class UploadCertificateResponse(msrest.serialization.Model): +class UploadCertificateResponse(_serialization.Model): """The upload registration certificate response. Variables are only populated by the server, and will be ignored when sending a request. - :param auth_type: Specifies authentication type. Possible values include: "Invalid", + :ivar auth_type: Specifies authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AuthenticationType + :vartype auth_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AuthenticationType :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. :vartype resource_id: str :ivar aad_authority: Azure Active Directory tenant authority. @@ -3340,33 +3626,33 @@ class UploadCertificateResponse(msrest.serialization.Model): """ _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, + "resource_id": {"readonly": True}, + "aad_authority": {"readonly": True}, + "aad_tenant_id": {"readonly": True}, + "service_principal_client_id": {"readonly": True}, + "service_principal_object_id": {"readonly": True}, + "azure_management_endpoint_audience": {"readonly": True}, + "aad_audience": {"readonly": True}, } _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, + "auth_type": {"key": "authType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "aad_authority": {"key": "aadAuthority", "type": "str"}, + "aad_tenant_id": {"key": "aadTenantId", "type": "str"}, + "service_principal_client_id": {"key": "servicePrincipalClientId", "type": "str"}, + "service_principal_object_id": {"key": "servicePrincipalObjectId", "type": "str"}, + "azure_management_endpoint_audience": {"key": "azureManagementEndpointAudience", "type": "str"}, + "aad_audience": {"key": "aadAudience", "type": "str"}, } - def __init__( - self, - *, - auth_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) + def __init__(self, *, auth_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs): + """ + :keyword auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype auth_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.AuthenticationType + """ + super().__init__(**kwargs) self.auth_type = auth_type self.resource_id = None self.aad_authority = None @@ -3390,81 +3676,95 @@ class User(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret - :param share_access_rights: List of shares that the user has rights on. This field should not - be specified during user creation. - :type share_access_rights: list[~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessRight] - :param user_type: Required. Type of the user. Possible values include: "Share", - "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.UserType + :ivar encrypted_password: The password details. + :vartype encrypted_password: + ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret + :ivar share_access_rights: List of shares that the user has rights on. This field should not be + specified during user creation. + :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessRight] + :ivar user_type: Type of the user. Required. Known values are: "Share", "LocalManagement", and + "ARM". + :vartype user_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.UserType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'user_type': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "user_type": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encrypted_password": {"key": "properties.encryptedPassword", "type": "AsymmetricEncryptedSecret"}, + "share_access_rights": {"key": "properties.shareAccessRights", "type": "[ShareAccessRight]"}, + "user_type": {"key": "properties.userType", "type": "str"}, } def __init__( self, *, - user_type: Union[str, "UserType"], - encrypted_password: Optional["AsymmetricEncryptedSecret"] = None, - share_access_rights: Optional[List["ShareAccessRight"]] = None, - **kwargs - ): - super(User, self).__init__(**kwargs) + user_type: Union[str, "_models.UserType"], + encrypted_password: Optional["_models.AsymmetricEncryptedSecret"] = None, + share_access_rights: Optional[List["_models.ShareAccessRight"]] = None, + **kwargs + ): + """ + :keyword encrypted_password: The password details. + :paramtype encrypted_password: + ~azure.mgmt.databoxedge.v2019_08_01.models.AsymmetricEncryptedSecret + :keyword share_access_rights: List of shares that the user has rights on. This field should not + be specified during user creation. + :paramtype share_access_rights: + list[~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessRight] + :keyword user_type: Type of the user. Required. Known values are: "Share", "LocalManagement", + and "ARM". + :paramtype user_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.UserType + """ + super().__init__(**kwargs) self.encrypted_password = encrypted_password self.share_access_rights = share_access_rights self.user_type = user_type -class UserAccessRight(msrest.serialization.Model): +class UserAccessRight(_serialization.Model): """The mapping between a particular user and the access type on the SMB share. All required parameters must be populated in order to send to Azure. - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessType + :ivar user_id: User ID (already existing in the device). Required. + :vartype user_id: str + :ivar access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessType """ _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, + "user_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, + "user_id": {"key": "userId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, } - def __init__( - self, - *, - user_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) + def __init__(self, *, user_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword user_id: User ID (already existing in the device). Required. + :paramtype user_id: str + :keyword access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2019_08_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.user_id = user_id self.access_type = access_type -class UserList(msrest.serialization.Model): +class UserList(_serialization.Model): """Collection of users. Variables are only populated by the server, and will be ignored when sending a request. @@ -3476,19 +3776,17 @@ class UserList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[User]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/__init__.py index 3897ada67557..19bf7b429223 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/__init__.py @@ -23,21 +23,27 @@ from ._users_operations import UsersOperations from ._skus_operations import SkusOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', - 'SkusOperations', + "Operations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_alerts_operations.py index c43d0a79ad7a..bcd50d54c199 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class AlertsOperations(object): - """AlertsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_by_data_box_edge_device_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,72 +206,73 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_bandwidth_schedules_operations.py index c865d71791de..9fedd2a53766 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,268 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class BandwidthSchedulesOperations(object): - """BandwidthSchedulesOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BandwidthSchedulesList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +276,126 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BandwidthSchedule" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BandwidthSchedule"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +404,215 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BandwidthSchedule"] + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +622,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_containers_operations.py index a02b4fcefa85..aec1bda7f415 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,329 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_storage_account_request( + device_name: str, storage_account_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ContainersOperations(object): - """ContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_storage_account( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ContainerList"] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,124 +337,135 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Container" + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Container"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -249,55 +474,149 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Container"] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2019_08_01.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Container or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2019_08_01.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -305,80 +624,75 @@ def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -388,121 +702,116 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -512,81 +821,79 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace def begin_refresh( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_devices_operations.py index 1dcf6c0a0e5d..9af1ca73de92 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,581 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", + ) # 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"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_download_updates_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_extended_information_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_install_updates_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_settings_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_scan_for_updates_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_security_settings_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class DevicesOperations(object): - """DevicesOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_update_summary_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_upload_certificate_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_subscription( - self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,75 +589,90 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + @distributed_trace def list_by_resource_group( - self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,230 +681,325 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } def _create_or_update_initial( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -425,174 +1009,243 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def update( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDevicePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - def _download_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -602,168 +1255,170 @@ def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } - def begin_download_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_download_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._download_updates_initial( + raw_result = self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace def get_extended_information( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - def _install_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -773,168 +1428,170 @@ def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } - def begin_install_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_install_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._install_updates_initial( + raw_result = self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace def get_network_settings( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkSettings" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - def _scan_for_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -944,115 +1601,124 @@ def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def begin_scan_for_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_scan_for_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._scan_for_updates_initial( + raw_result = self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def _create_or_update_security_settings_initial( + def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1062,202 +1728,353 @@ def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload def begin_create_or_update_security_settings( self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2019_08_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2019_08_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_security_settings_initial( + raw_result = self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def get_update_summary( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateSummary" - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @distributed_trace + def get_update_summary(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload def upload_certificate( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.UploadCertificateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.UploadCertificateResponse" + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_jobs_operations.py index ae64fe0e955b..4b35c9b1a611 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class JobsOperations(object): - """JobsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_nodes_operations.py index c5a09a62691f..73c544491897 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,166 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class NodesOperations(object): - """NodesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NodeList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +174,8 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_operations.py index 60e166c69f05..f83f07e16a51 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") -class Operations(object): - """Operations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataBoxEdge/operations") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +155,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_operations_status_operations.py index a30d82757482..70145acd95b2 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class OperationsStatusOperations(object): - """OperationsStatusOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_orders_operations.py index 52461cd4e254..8e8a1a27fc6b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,264 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request(device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class OrdersOperations(object): - """OrdersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OrderList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,112 +272,119 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Order" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } def _create_or_update_initial( - self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Order"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,122 +393,200 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Order"] + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2019_08_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2019_08_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,71 +596,71 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_roles_operations.py index 23cab2b31e98..91f6fcd3bd94 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,267 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class RolesOperations(object): - """RolesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +275,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Role" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Role"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +398,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Role"] + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2019_08_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2019_08_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +604,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_shares_operations.py index d654bbcb61f5..bde963173d6b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,301 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_delete_request( + device_name: str, name: str, 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 {}) -class SharesOperations(object): - """SharesOperations operations. + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ShareList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +309,123 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Share" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Share"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +434,209 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Share"] + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2019_08_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2019_08_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,114 +646,110 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -488,76 +759,74 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } - def begin_refresh( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_refresh(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_skus_operations.py index 1676918728c2..cbd54839c94e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,160 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } -class SkusOperations(object): - """SkusOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SkuInformationList"] + 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 list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.ResourceTypeSku"]: """List all the available Skus in the region and information related to them. List all the available Skus in the region and information related to them. - :param filter: Specify $filter='location eq :code:``' to filter on location. + :param filter: Specify $filter='location eq :code:``' to filter on location. Default + value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkuInformationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.SkuInformationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceTypeSku or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.ResourceTypeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuInformationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.SkuInformationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SkuInformationList', pipeline_response) + deserialized = self._deserialize("SkuInformationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,7 +168,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_storage_account_credentials_operations.py index 137137688679..6949271a416d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,271 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class StorageAccountCredentialsOperations(object): - """StorageAccountCredentialsOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountCredentialList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,116 +279,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountCredential" + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccountCredential"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -237,127 +409,217 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccountCredential"] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -367,74 +629,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_storage_accounts_operations.py index 2cfe010aaaf3..1354640266ef 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,269 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, storage_account_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, storage_account_name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, storage_account_name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts in a Data Box Edge/Data Box Gateway device. Lists all the storage accounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +277,130 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccount" + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccount"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +409,221 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccount"] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -371,74 +633,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_triggers_operations.py index 4c849f643f23..99d2f296f9f7 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,273 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class TriggersOperations(object): - """TriggersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TriggerList"] + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +281,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Trigger" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Trigger"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,127 +404,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Trigger"] + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2019_08_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Trigger or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2019_08_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +610,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_users_operations.py index 2a8deed319aa..fc0a12cb9179 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2019_08_01/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,115 +6,273 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class UsersOperations(object): - """UsersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2019_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2019_08_01.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserList"] + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='UserType eq :code:``' to filter on user type property. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2019_08_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,116 +281,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2019_08_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.User"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -240,128 +404,206 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.User"] + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2019_08_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2019_08_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2019_08_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +613,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2019-08-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/__init__.py index e63196b6b98f..d2bcf6a47896 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/__init__.py @@ -7,10 +7,20 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_configuration.py index be5da99674c4..8c4f29b6c9b4 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_configuration.py @@ -6,65 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-05-01-preview"] = kwargs.pop("api_version", "2020-05-01-preview") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-05-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_data_box_edge_management_client.py index 8cbea50f1d6a..2bf357e7d311 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_data_box_edge_management_client.py @@ -6,58 +6,62 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + SkusOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .operations import SkusOperations -from . import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.databoxedge.v2020_05_01_preview.operations.Operations :ivar available_skus: AvailableSkusOperations operations - :vartype available_skus: azure.mgmt.databoxedge.v2020_05_01_preview.operations.AvailableSkusOperations + :vartype available_skus: + azure.mgmt.databoxedge.v2020_05_01_preview.operations.AvailableSkusOperations :ivar devices: DevicesOperations operations :vartype devices: azure.mgmt.databoxedge.v2020_05_01_preview.operations.DevicesOperations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2020_05_01_preview.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2020_05_01_preview.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2020_05_01_preview.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2020_05_01_preview.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2020_05_01_preview.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2020_05_01_preview.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2020_05_01_preview.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2020_05_01_preview.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -65,9 +69,11 @@ class DataBoxEdgeManagementClient(object): :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2020_05_01_preview.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2020_05_01_preview.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2020_05_01_preview.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2020_05_01_preview.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2020_05_01_preview.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations :vartype containers: azure.mgmt.databoxedge.v2020_05_01_preview.operations.ContainersOperations :ivar triggers: TriggersOperations operations @@ -76,94 +82,89 @@ class DataBoxEdgeManagementClient(object): :vartype users: azure.mgmt.databoxedge.v2020_05_01_preview.operations.UsersOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.databoxedge.v2020_05_01_preview.operations.SkusOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-05-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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None + + 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) -> None: self._client.close() - def __enter__(self): - # type: () -> DataBoxEdgeManagementClient + def __enter__(self) -> "DataBoxEdgeManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_metadata.json b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_metadata.json index f54cc3d6befb..05c4fce4fb6b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_metadata.json +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_metadata.json @@ -5,25 +5,25 @@ "name": "DataBoxEdgeManagementClient", "filename": "_data_box_edge_management_client", "description": "The DataBoxEdge Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription ID.", + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription ID.", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=None, # type: Optional[str]", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -116,4 +115,4 @@ "users": "UsersOperations", "skus": "SkusOperations" } -} \ No newline at end of file +} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_vendor.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_version.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/__init__.py index c33d46ee91d8..fcb8775eaa10 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_configuration.py index 4f2e69f832d1..13994024d238 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_configuration.py @@ -6,61 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-05-01-preview"] = kwargs.pop("api_version", "2020-05-01-preview") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-05-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_data_box_edge_management_client.py index a7fbbc2ca877..e54bc9b631a3 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_data_box_edge_management_client.py @@ -6,56 +6,62 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + SkusOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .operations import SkusOperations -from .. import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.Operations :ivar available_skus: AvailableSkusOperations operations - :vartype available_skus: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.AvailableSkusOperations + :vartype available_skus: + azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.AvailableSkusOperations :ivar devices: DevicesOperations operations :vartype devices: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.DevicesOperations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -63,93 +69,96 @@ class DataBoxEdgeManagementClient(object): :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations - :vartype containers: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.ContainersOperations + :vartype containers: + azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.ContainersOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.UsersOperations :ivar skus: SkusOperations operations :vartype skus: azure.mgmt.databoxedge.v2020_05_01_preview.aio.operations.SkusOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-05-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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/__init__.py index 94a6a27f766b..a5b67b917b67 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/__init__.py @@ -24,22 +24,28 @@ from ._users_operations import UsersOperations from ._skus_operations import SkusOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', - 'SkusOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_alerts_operations.py index 9cc9132e3f68..e324cf3218e3 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._alerts_operations import build_get_request, build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AlertsOperations: - """AlertsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AlertList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,71 +144,75 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Alert": + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_available_skus_operations.py index 3c1e56b6a241..bc4df060458f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,129 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._available_skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AvailableSkusOperations: - """AvailableSkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeSkuList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +137,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_bandwidth_schedules_operations.py index 462909541584..9810a105ea5d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._bandwidth_schedules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BandwidthSchedulesOperations: - """BandwidthSchedulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.BandwidthSchedulesList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +151,132 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.BandwidthSchedule": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> Optional["_models.BandwidthSchedule"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +285,219 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> AsyncLROPoller["_models.BandwidthSchedule"]: + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +507,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_containers_operations.py index 5db7070e2ddc..125e059b86cf 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,149 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._containers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_storage_account_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainersOperations: - """ContainersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_storage_account( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ContainerList"]: + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,78 +157,83 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Container": + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } async def _create_or_update_initial( self, @@ -197,43 +241,55 @@ async def _create_or_update_initial( storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> Optional["_models.Container"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -242,54 +298,157 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> AsyncLROPoller["_models.Container"]: + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Container or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -297,79 +456,77 @@ async def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -379,119 +536,120 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -501,80 +659,81 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_devices_operations.py index 0d9c4106ed4f..b368edf2c661 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._devices_operations import ( + build_create_or_update_request, + build_create_or_update_security_settings_request, + build_delete_request, + build_download_updates_request, + build_get_extended_information_request, + build_get_network_settings_request, + build_get_request, + build_get_update_summary_request, + build_install_updates_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_scan_for_updates_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations: - """DevicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_subscription( - self, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,74 +160,92 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,226 +254,335 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDevice": + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } async def _create_or_update_initial( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> "_models.DataBoxEdgeDevice": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async async def begin_create_or_update( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> AsyncLROPoller["_models.DataBoxEdgeDevice"]: + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. - :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -415,171 +592,250 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload async def update( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDevicePatch", - **kwargs - ) -> "_models.DataBoxEdgeDevice": + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevicePatch or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - async def _download_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -589,165 +845,178 @@ async def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def begin_download_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._download_updates_initial( + raw_result = await self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def get_extended_information( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - async def _install_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + async def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -757,165 +1026,178 @@ async def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def begin_install_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._install_updates_initial( + raw_result = await self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + + @distributed_trace_async async def get_network_settings( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.NetworkSettings": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - async def _scan_for_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + async def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -925,113 +1207,130 @@ async def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + @distributed_trace_async async def begin_scan_for_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._scan_for_updates_initial( + raw_result = await self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - async def _create_or_update_security_settings_initial( + async def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1041,199 +1340,363 @@ async def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload async def begin_create_or_update_security_settings( self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SecuritySettings or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_security_settings_initial( + raw_result = await self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @distributed_trace_async async def get_update_summary( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.UpdateSummary": - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload async def upload_certificate( self, device_name: str, resource_group_name: str, - parameters: "_models.UploadCertificateRequest", - **kwargs - ) -> "_models.UploadCertificateResponse": + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_jobs_operations.py index 3a746f7e258a..e6169f67bb1f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class JobsOperations: - """JobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_nodes_operations.py index 7a91dc86646b..9ca24674655e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._nodes_operations import build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NodesOperations: - """NodesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.NodeList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +143,8 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_operations.py index 93b421dea3fc..0d9118f3017d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.OperationsList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +136,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_operations_status_operations.py index 9057292e9c95..024c892f487c 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations_status_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsStatusOperations: - """OperationsStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_orders_operations.py index 565453e7585c..0ff02bd94877 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._orders_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OrdersOperations: - """OrdersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.OrderList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,110 +153,123 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Order": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } async def _create_or_update_initial( - self, - device_name: str, - resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> Optional["_models.Order"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -226,120 +278,207 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> AsyncLROPoller["_models.Order"]: + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Order or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -349,70 +488,73 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_roles_operations.py index adc1ae3c4fb4..d0ff381801e2 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._roles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RolesOperations: - """RolesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.RoleList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +151,125 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Role": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> Optional["_models.Role"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +278,210 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> AsyncLROPoller["_models.Role"]: + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Role or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +491,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_shares_operations.py index 1771708a1408..62d4e3410a7f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._shares_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SharesOperations: - """SharesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ShareList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +154,127 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Share": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> Optional["_models.Share"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +283,216 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> AsyncLROPoller["_models.Share"]: + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Share or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,112 +502,116 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -477,75 +621,78 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_skus_operations.py index 228a2c7841be..eefa5e21def0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SkusOperations: - """SkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.SkuInformationList"]: + 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 + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.ResourceTypeSku"]: """List all the available Skus in the region and information related to them. List all the available Skus in the region and information related to them. - :param filter: Specify $filter='location eq :code:``' to filter on location. + :param filter: Specify $filter='location eq :code:``' to filter on location. Default + value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkuInformationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuInformationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceTypeSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ResourceTypeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuInformationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.SkuInformationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SkuInformationList', pipeline_response) + deserialized = self._deserialize("SkuInformationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,7 +141,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_storage_account_credentials_operations.py index 02f5294dfcc7..61a9f10cad2e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_account_credentials_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountCredentialsOperations: - """StorageAccountCredentialsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountCredentialList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,114 +154,132 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccountCredential": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> Optional["_models.StorageAccountCredential"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -230,125 +288,221 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccountCredential"]: + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,73 +512,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_storage_accounts_operations.py index 86a4c0757ba9..7b56fd112205 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_accounts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountsOperations: - """StorageAccountsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts in a Data Box Edge/Data Box Gateway device. Lists all the storage accounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +153,134 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccount": + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } async def _create_or_update_initial( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +289,225 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccount"]: + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -362,73 +517,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_triggers_operations.py index def269de6448..a4180f849e51 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._triggers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TriggersOperations: - """TriggersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.TriggerList"]: + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +155,125 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Trigger": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> Optional["_models.Trigger"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,125 +282,213 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> AsyncLROPoller["_models.Trigger"]: + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Trigger or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Trigger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +498,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_users_operations.py index b839c9783245..eea34f33694b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UsersOperations: - """UsersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.UserList"]: + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='UserType eq :code:``' to filter on user type property. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,114 +155,125 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.User": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - user: "_models.User", - **kwargs - ) -> Optional["_models.User"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,126 +282,213 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - user: "_models.User", - **kwargs - ) -> AsyncLROPoller["_models.User"]: + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +498,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/__init__.py index 2d4899f0eba8..4128df8fc28a 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/__init__.py @@ -6,349 +6,268 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARMBaseModel - from ._models_py3 import Address - from ._models_py3 import Alert - from ._models_py3 import AlertErrorDetails - from ._models_py3 import AlertList - from ._models_py3 import AsymmetricEncryptedSecret - from ._models_py3 import Authentication - from ._models_py3 import AzureContainerInfo - from ._models_py3 import BandwidthSchedule - from ._models_py3 import BandwidthSchedulesList - from ._models_py3 import ClientAccessRight - from ._models_py3 import CloudErrorBody - from ._models_py3 import ContactDetails - from ._models_py3 import Container - from ._models_py3 import ContainerList - from ._models_py3 import DataBoxEdgeDevice - from ._models_py3 import DataBoxEdgeDeviceExtendedInfo - from ._models_py3 import DataBoxEdgeDeviceList - from ._models_py3 import DataBoxEdgeDevicePatch - from ._models_py3 import DataBoxEdgeSku - from ._models_py3 import DataBoxEdgeSkuList - from ._models_py3 import FileEventTrigger - from ._models_py3 import FileSourceInfo - from ._models_py3 import ImageRepositoryCredential - from ._models_py3 import IoTDeviceInfo - from ._models_py3 import IoTEdgeAgentInfo - from ._models_py3 import IoTRole - from ._models_py3 import Ipv4Config - from ._models_py3 import Ipv6Config - from ._models_py3 import Job - from ._models_py3 import JobErrorDetails - from ._models_py3 import JobErrorItem - from ._models_py3 import MetricDimensionV1 - from ._models_py3 import MetricSpecificationV1 - from ._models_py3 import MountPointMap - from ._models_py3 import NetworkAdapter - from ._models_py3 import NetworkAdapterPosition - from ._models_py3 import NetworkSettings - from ._models_py3 import Node - from ._models_py3 import NodeList - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import Order - from ._models_py3 import OrderList - from ._models_py3 import OrderStatus - from ._models_py3 import PeriodicTimerEventTrigger - from ._models_py3 import PeriodicTimerSourceInfo - from ._models_py3 import RefreshDetails - from ._models_py3 import ResourceTypeSku - from ._models_py3 import Role - from ._models_py3 import RoleList - from ._models_py3 import RoleSinkInfo - from ._models_py3 import SKUCapability - from ._models_py3 import SecuritySettings - from ._models_py3 import ServiceSpecification - from ._models_py3 import Share - from ._models_py3 import ShareAccessRight - from ._models_py3 import ShareList - from ._models_py3 import Sku - from ._models_py3 import SkuCost - from ._models_py3 import SkuInformation - from ._models_py3 import SkuInformationList - from ._models_py3 import SkuLocationInfo - from ._models_py3 import SkuRestriction - from ._models_py3 import SkuRestrictionInfo - from ._models_py3 import StorageAccount - from ._models_py3 import StorageAccountCredential - from ._models_py3 import StorageAccountCredentialList - from ._models_py3 import StorageAccountList - from ._models_py3 import SymmetricKey - from ._models_py3 import TrackingInfo - from ._models_py3 import Trigger - from ._models_py3 import TriggerList - from ._models_py3 import UpdateDownloadProgress - from ._models_py3 import UpdateInstallProgress - from ._models_py3 import UpdateSummary - from ._models_py3 import UploadCertificateRequest - from ._models_py3 import UploadCertificateResponse - from ._models_py3 import User - from ._models_py3 import UserAccessRight - from ._models_py3 import UserList -except (SyntaxError, ImportError): - from ._models import ARMBaseModel # type: ignore - from ._models import Address # type: ignore - from ._models import Alert # type: ignore - from ._models import AlertErrorDetails # type: ignore - from ._models import AlertList # type: ignore - from ._models import AsymmetricEncryptedSecret # type: ignore - from ._models import Authentication # type: ignore - from ._models import AzureContainerInfo # type: ignore - from ._models import BandwidthSchedule # type: ignore - from ._models import BandwidthSchedulesList # type: ignore - from ._models import ClientAccessRight # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import ContactDetails # type: ignore - from ._models import Container # type: ignore - from ._models import ContainerList # type: ignore - from ._models import DataBoxEdgeDevice # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfo # type: ignore - from ._models import DataBoxEdgeDeviceList # type: ignore - from ._models import DataBoxEdgeDevicePatch # type: ignore - from ._models import DataBoxEdgeSku # type: ignore - from ._models import DataBoxEdgeSkuList # type: ignore - from ._models import FileEventTrigger # type: ignore - from ._models import FileSourceInfo # type: ignore - from ._models import ImageRepositoryCredential # type: ignore - from ._models import IoTDeviceInfo # type: ignore - from ._models import IoTEdgeAgentInfo # type: ignore - from ._models import IoTRole # type: ignore - from ._models import Ipv4Config # type: ignore - from ._models import Ipv6Config # type: ignore - from ._models import Job # type: ignore - from ._models import JobErrorDetails # type: ignore - from ._models import JobErrorItem # type: ignore - from ._models import MetricDimensionV1 # type: ignore - from ._models import MetricSpecificationV1 # type: ignore - from ._models import MountPointMap # type: ignore - from ._models import NetworkAdapter # type: ignore - from ._models import NetworkAdapterPosition # type: ignore - from ._models import NetworkSettings # type: ignore - from ._models import Node # type: ignore - from ._models import NodeList # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import Order # type: ignore - from ._models import OrderList # type: ignore - from ._models import OrderStatus # type: ignore - from ._models import PeriodicTimerEventTrigger # type: ignore - from ._models import PeriodicTimerSourceInfo # type: ignore - from ._models import RefreshDetails # type: ignore - from ._models import ResourceTypeSku # type: ignore - from ._models import Role # type: ignore - from ._models import RoleList # type: ignore - from ._models import RoleSinkInfo # type: ignore - from ._models import SKUCapability # type: ignore - from ._models import SecuritySettings # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Share # type: ignore - from ._models import ShareAccessRight # type: ignore - from ._models import ShareList # type: ignore - from ._models import Sku # type: ignore - from ._models import SkuCost # type: ignore - from ._models import SkuInformation # type: ignore - from ._models import SkuInformationList # type: ignore - from ._models import SkuLocationInfo # type: ignore - from ._models import SkuRestriction # type: ignore - from ._models import SkuRestrictionInfo # type: ignore - from ._models import StorageAccount # type: ignore - from ._models import StorageAccountCredential # type: ignore - from ._models import StorageAccountCredentialList # type: ignore - from ._models import StorageAccountList # type: ignore - from ._models import SymmetricKey # type: ignore - from ._models import TrackingInfo # type: ignore - from ._models import Trigger # type: ignore - from ._models import TriggerList # type: ignore - from ._models import UpdateDownloadProgress # type: ignore - from ._models import UpdateInstallProgress # type: ignore - from ._models import UpdateSummary # type: ignore - from ._models import UploadCertificateRequest # type: ignore - from ._models import UploadCertificateResponse # type: ignore - from ._models import User # type: ignore - from ._models import UserAccessRight # type: ignore - from ._models import UserList # type: ignore +from ._models_py3 import ARMBaseModel +from ._models_py3 import Address +from ._models_py3 import Alert +from ._models_py3 import AlertErrorDetails +from ._models_py3 import AlertList +from ._models_py3 import AsymmetricEncryptedSecret +from ._models_py3 import Authentication +from ._models_py3 import AzureContainerInfo +from ._models_py3 import BandwidthSchedule +from ._models_py3 import BandwidthSchedulesList +from ._models_py3 import ClientAccessRight +from ._models_py3 import CloudErrorBody +from ._models_py3 import ContactDetails +from ._models_py3 import Container +from ._models_py3 import ContainerList +from ._models_py3 import DataBoxEdgeDevice +from ._models_py3 import DataBoxEdgeDeviceExtendedInfo +from ._models_py3 import DataBoxEdgeDeviceList +from ._models_py3 import DataBoxEdgeDevicePatch +from ._models_py3 import DataBoxEdgeSku +from ._models_py3 import DataBoxEdgeSkuList +from ._models_py3 import FileEventTrigger +from ._models_py3 import FileSourceInfo +from ._models_py3 import ImageRepositoryCredential +from ._models_py3 import IoTDeviceInfo +from ._models_py3 import IoTEdgeAgentInfo +from ._models_py3 import IoTRole +from ._models_py3 import Ipv4Config +from ._models_py3 import Ipv6Config +from ._models_py3 import Job +from ._models_py3 import JobErrorDetails +from ._models_py3 import JobErrorItem +from ._models_py3 import MetricDimensionV1 +from ._models_py3 import MetricSpecificationV1 +from ._models_py3 import MountPointMap +from ._models_py3 import NetworkAdapter +from ._models_py3 import NetworkAdapterPosition +from ._models_py3 import NetworkSettings +from ._models_py3 import Node +from ._models_py3 import NodeList +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import Order +from ._models_py3 import OrderList +from ._models_py3 import OrderStatus +from ._models_py3 import PeriodicTimerEventTrigger +from ._models_py3 import PeriodicTimerSourceInfo +from ._models_py3 import RefreshDetails +from ._models_py3 import ResourceTypeSku +from ._models_py3 import Role +from ._models_py3 import RoleList +from ._models_py3 import RoleSinkInfo +from ._models_py3 import SKUCapability +from ._models_py3 import SecuritySettings +from ._models_py3 import ServiceSpecification +from ._models_py3 import Share +from ._models_py3 import ShareAccessRight +from ._models_py3 import ShareList +from ._models_py3 import Sku +from ._models_py3 import SkuCost +from ._models_py3 import SkuInformation +from ._models_py3 import SkuInformationList +from ._models_py3 import SkuLocationInfo +from ._models_py3 import SkuRestriction +from ._models_py3 import SkuRestrictionInfo +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCredential +from ._models_py3 import StorageAccountCredentialList +from ._models_py3 import StorageAccountList +from ._models_py3 import SymmetricKey +from ._models_py3 import TrackingInfo +from ._models_py3 import Trigger +from ._models_py3 import TriggerList +from ._models_py3 import UpdateDownloadProgress +from ._models_py3 import UpdateInstallProgress +from ._models_py3 import UpdateSummary +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UploadCertificateResponse +from ._models_py3 import User +from ._models_py3 import UserAccessRight +from ._models_py3 import UserList -from ._data_box_edge_management_client_enums import ( - AccountType, - AlertSeverity, - AuthenticationType, - AzureContainerDataFormat, - ClientPermissionType, - ContainerStatus, - DataBoxEdgeDeviceStatus, - DataPolicy, - DayOfWeek, - DeviceType, - DownloadPhase, - EncryptionAlgorithm, - HostPlatformType, - InstallRebootBehavior, - JobStatus, - JobType, - MetricAggregationType, - MetricCategory, - MetricUnit, - MonitoringStatus, - MountType, - NetworkAdapterDHCPStatus, - NetworkAdapterRDMAStatus, - NetworkAdapterStatus, - NetworkGroup, - NodeStatus, - OrderState, - PlatformType, - RoleStatus, - RoleTypes, - SSLStatus, - ShareAccessProtocol, - ShareAccessType, - ShareStatus, - SkuAvailability, - SkuName, - SkuRestrictionReasonCode, - SkuSignupOption, - SkuTier, - SkuVersion, - StorageAccountStatus, - TimeGrain, - TriggerEventType, - UpdateOperation, - UpdateOperationStage, - UserType, -) +from ._data_box_edge_management_client_enums import AccountType +from ._data_box_edge_management_client_enums import AlertSeverity +from ._data_box_edge_management_client_enums import AuthenticationType +from ._data_box_edge_management_client_enums import AzureContainerDataFormat +from ._data_box_edge_management_client_enums import ClientPermissionType +from ._data_box_edge_management_client_enums import ContainerStatus +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceStatus +from ._data_box_edge_management_client_enums import DataPolicy +from ._data_box_edge_management_client_enums import DayOfWeek +from ._data_box_edge_management_client_enums import DeviceType +from ._data_box_edge_management_client_enums import DownloadPhase +from ._data_box_edge_management_client_enums import EncryptionAlgorithm +from ._data_box_edge_management_client_enums import HostPlatformType +from ._data_box_edge_management_client_enums import InstallRebootBehavior +from ._data_box_edge_management_client_enums import JobStatus +from ._data_box_edge_management_client_enums import JobType +from ._data_box_edge_management_client_enums import MetricAggregationType +from ._data_box_edge_management_client_enums import MetricCategory +from ._data_box_edge_management_client_enums import MetricUnit +from ._data_box_edge_management_client_enums import MonitoringStatus +from ._data_box_edge_management_client_enums import MountType +from ._data_box_edge_management_client_enums import NetworkAdapterDHCPStatus +from ._data_box_edge_management_client_enums import NetworkAdapterRDMAStatus +from ._data_box_edge_management_client_enums import NetworkAdapterStatus +from ._data_box_edge_management_client_enums import NetworkGroup +from ._data_box_edge_management_client_enums import NodeStatus +from ._data_box_edge_management_client_enums import OrderState +from ._data_box_edge_management_client_enums import PlatformType +from ._data_box_edge_management_client_enums import RoleStatus +from ._data_box_edge_management_client_enums import RoleTypes +from ._data_box_edge_management_client_enums import SSLStatus +from ._data_box_edge_management_client_enums import ShareAccessProtocol +from ._data_box_edge_management_client_enums import ShareAccessType +from ._data_box_edge_management_client_enums import ShareStatus +from ._data_box_edge_management_client_enums import SkuAvailability +from ._data_box_edge_management_client_enums import SkuName +from ._data_box_edge_management_client_enums import SkuRestrictionReasonCode +from ._data_box_edge_management_client_enums import SkuSignupOption +from ._data_box_edge_management_client_enums import SkuTier +from ._data_box_edge_management_client_enums import SkuVersion +from ._data_box_edge_management_client_enums import StorageAccountStatus +from ._data_box_edge_management_client_enums import TimeGrain +from ._data_box_edge_management_client_enums import TriggerEventType +from ._data_box_edge_management_client_enums import UpdateOperation +from ._data_box_edge_management_client_enums import UpdateOperationStage +from ._data_box_edge_management_client_enums import UserType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ARMBaseModel', - 'Address', - 'Alert', - 'AlertErrorDetails', - 'AlertList', - 'AsymmetricEncryptedSecret', - 'Authentication', - 'AzureContainerInfo', - 'BandwidthSchedule', - 'BandwidthSchedulesList', - 'ClientAccessRight', - 'CloudErrorBody', - 'ContactDetails', - 'Container', - 'ContainerList', - 'DataBoxEdgeDevice', - 'DataBoxEdgeDeviceExtendedInfo', - 'DataBoxEdgeDeviceList', - 'DataBoxEdgeDevicePatch', - 'DataBoxEdgeSku', - 'DataBoxEdgeSkuList', - 'FileEventTrigger', - 'FileSourceInfo', - 'ImageRepositoryCredential', - 'IoTDeviceInfo', - 'IoTEdgeAgentInfo', - 'IoTRole', - 'Ipv4Config', - 'Ipv6Config', - 'Job', - 'JobErrorDetails', - 'JobErrorItem', - 'MetricDimensionV1', - 'MetricSpecificationV1', - 'MountPointMap', - 'NetworkAdapter', - 'NetworkAdapterPosition', - 'NetworkSettings', - 'Node', - 'NodeList', - 'Operation', - 'OperationDisplay', - 'OperationsList', - 'Order', - 'OrderList', - 'OrderStatus', - 'PeriodicTimerEventTrigger', - 'PeriodicTimerSourceInfo', - 'RefreshDetails', - 'ResourceTypeSku', - 'Role', - 'RoleList', - 'RoleSinkInfo', - 'SKUCapability', - 'SecuritySettings', - 'ServiceSpecification', - 'Share', - 'ShareAccessRight', - 'ShareList', - 'Sku', - 'SkuCost', - 'SkuInformation', - 'SkuInformationList', - 'SkuLocationInfo', - 'SkuRestriction', - 'SkuRestrictionInfo', - 'StorageAccount', - 'StorageAccountCredential', - 'StorageAccountCredentialList', - 'StorageAccountList', - 'SymmetricKey', - 'TrackingInfo', - 'Trigger', - 'TriggerList', - 'UpdateDownloadProgress', - 'UpdateInstallProgress', - 'UpdateSummary', - 'UploadCertificateRequest', - 'UploadCertificateResponse', - 'User', - 'UserAccessRight', - 'UserList', - 'AccountType', - 'AlertSeverity', - 'AuthenticationType', - 'AzureContainerDataFormat', - 'ClientPermissionType', - 'ContainerStatus', - 'DataBoxEdgeDeviceStatus', - 'DataPolicy', - 'DayOfWeek', - 'DeviceType', - 'DownloadPhase', - 'EncryptionAlgorithm', - 'HostPlatformType', - 'InstallRebootBehavior', - 'JobStatus', - 'JobType', - 'MetricAggregationType', - 'MetricCategory', - 'MetricUnit', - 'MonitoringStatus', - 'MountType', - 'NetworkAdapterDHCPStatus', - 'NetworkAdapterRDMAStatus', - 'NetworkAdapterStatus', - 'NetworkGroup', - 'NodeStatus', - 'OrderState', - 'PlatformType', - 'RoleStatus', - 'RoleTypes', - 'SSLStatus', - 'ShareAccessProtocol', - 'ShareAccessType', - 'ShareStatus', - 'SkuAvailability', - 'SkuName', - 'SkuRestrictionReasonCode', - 'SkuSignupOption', - 'SkuTier', - 'SkuVersion', - 'StorageAccountStatus', - 'TimeGrain', - 'TriggerEventType', - 'UpdateOperation', - 'UpdateOperationStage', - 'UserType', + "ARMBaseModel", + "Address", + "Alert", + "AlertErrorDetails", + "AlertList", + "AsymmetricEncryptedSecret", + "Authentication", + "AzureContainerInfo", + "BandwidthSchedule", + "BandwidthSchedulesList", + "ClientAccessRight", + "CloudErrorBody", + "ContactDetails", + "Container", + "ContainerList", + "DataBoxEdgeDevice", + "DataBoxEdgeDeviceExtendedInfo", + "DataBoxEdgeDeviceList", + "DataBoxEdgeDevicePatch", + "DataBoxEdgeSku", + "DataBoxEdgeSkuList", + "FileEventTrigger", + "FileSourceInfo", + "ImageRepositoryCredential", + "IoTDeviceInfo", + "IoTEdgeAgentInfo", + "IoTRole", + "Ipv4Config", + "Ipv6Config", + "Job", + "JobErrorDetails", + "JobErrorItem", + "MetricDimensionV1", + "MetricSpecificationV1", + "MountPointMap", + "NetworkAdapter", + "NetworkAdapterPosition", + "NetworkSettings", + "Node", + "NodeList", + "Operation", + "OperationDisplay", + "OperationsList", + "Order", + "OrderList", + "OrderStatus", + "PeriodicTimerEventTrigger", + "PeriodicTimerSourceInfo", + "RefreshDetails", + "ResourceTypeSku", + "Role", + "RoleList", + "RoleSinkInfo", + "SKUCapability", + "SecuritySettings", + "ServiceSpecification", + "Share", + "ShareAccessRight", + "ShareList", + "Sku", + "SkuCost", + "SkuInformation", + "SkuInformationList", + "SkuLocationInfo", + "SkuRestriction", + "SkuRestrictionInfo", + "StorageAccount", + "StorageAccountCredential", + "StorageAccountCredentialList", + "StorageAccountList", + "SymmetricKey", + "TrackingInfo", + "Trigger", + "TriggerList", + "UpdateDownloadProgress", + "UpdateInstallProgress", + "UpdateSummary", + "UploadCertificateRequest", + "UploadCertificateResponse", + "User", + "UserAccessRight", + "UserList", + "AccountType", + "AlertSeverity", + "AuthenticationType", + "AzureContainerDataFormat", + "ClientPermissionType", + "ContainerStatus", + "DataBoxEdgeDeviceStatus", + "DataPolicy", + "DayOfWeek", + "DeviceType", + "DownloadPhase", + "EncryptionAlgorithm", + "HostPlatformType", + "InstallRebootBehavior", + "JobStatus", + "JobType", + "MetricAggregationType", + "MetricCategory", + "MetricUnit", + "MonitoringStatus", + "MountType", + "NetworkAdapterDHCPStatus", + "NetworkAdapterRDMAStatus", + "NetworkAdapterStatus", + "NetworkGroup", + "NodeStatus", + "OrderState", + "PlatformType", + "RoleStatus", + "RoleTypes", + "SSLStatus", + "ShareAccessProtocol", + "ShareAccessType", + "ShareStatus", + "SkuAvailability", + "SkuName", + "SkuRestrictionReasonCode", + "SkuSignupOption", + "SkuTier", + "SkuVersion", + "StorageAccountStatus", + "TimeGrain", + "TriggerEventType", + "UpdateOperation", + "UpdateOperationStage", + "UserType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_data_box_edge_management_client_enums.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_data_box_edge_management_client_enums.py index cef0587a6c20..4a56d95cd55e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_data_box_edge_management_client_enums.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_data_box_edge_management_client_enums.py @@ -6,67 +6,50 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of storage accessed on the storage account. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of storage accessed on the storage account.""" GENERAL_PURPOSE_STORAGE = "GeneralPurposeStorage" BLOB_STORAGE = "BlobStorage" -class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the alert. - """ + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert.""" INFORMATIONAL = "Informational" WARNING = "Warning" CRITICAL = "Critical" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The authentication type. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication type.""" INVALID = "Invalid" AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" -class AzureContainerDataFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Storage format used for the file represented by the share. - """ + +class AzureContainerDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage format used for the file represented by the share.""" BLOCK_BLOB = "BlockBlob" PAGE_BLOB = "PageBlob" AZURE_FILE = "AzureFile" -class ClientPermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed for the client. - """ + +class ClientPermissionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed for the client.""" NO_ACCESS = "NoAccess" READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the container. - """ + +class ContainerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the container.""" OK = "OK" OFFLINE = "Offline" @@ -74,9 +57,9 @@ class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the Data Box Edge/Gateway device. - """ + +class DataBoxEdgeDeviceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the Data Box Edge/Gateway device.""" READY_TO_SETUP = "ReadyToSetup" ONLINE = "Online" @@ -86,14 +69,16 @@ class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum PARTIALLY_DISCONNECTED = "PartiallyDisconnected" MAINTENANCE = "Maintenance" -class DataPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Data policy of the share. - """ + +class DataPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data policy of the share.""" CLOUD = "Cloud" LOCAL = "Local" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -103,47 +88,47 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DeviceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the Data Box Edge/Gateway device. - """ + +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the Data Box Edge/Gateway device.""" DATA_BOX_EDGE_DEVICE = "DataBoxEdgeDevice" -class DownloadPhase(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The download phase. - """ + +class DownloadPhase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The download phase.""" UNKNOWN = "Unknown" INITIALIZING = "Initializing" DOWNLOADING = "Downloading" VERIFYING = "Verifying" -class EncryptionAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The algorithm used to encrypt "Value". - """ + +class EncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The algorithm used to encrypt "Value".""" NONE = "None" AES256 = "AES256" RSAES_PKCS1_V1_5 = "RSAES_PKCS1_v_1_5" -class HostPlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Platform where the Iot runtime is hosted. - """ + +class HostPlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Platform where the Iot runtime is hosted.""" KUBERNETES_CLUSTER = "KubernetesCluster" LINUX_VM = "LinuxVM" -class InstallRebootBehavior(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if updates are available and at least one of the updates needs a reboot. - """ + +class InstallRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if updates are available and at least one of the updates needs a reboot.""" NEVER_REBOOTS = "NeverReboots" REQUIRES_REBOOT = "RequiresReboot" REQUEST_REBOOT = "RequestReboot" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the job.""" INVALID = "Invalid" RUNNING = "Running" @@ -153,9 +138,9 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PAUSED = "Paused" SCHEDULED = "Scheduled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" INVALID = "Invalid" SCAN_FOR_UPDATES = "ScanForUpdates" @@ -164,9 +149,9 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REFRESH_SHARE = "RefreshShare" REFRESH_CONTAINER = "RefreshContainer" -class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric aggregation type. - """ + +class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric aggregation type.""" NOT_SPECIFIED = "NotSpecified" NONE = "None" @@ -176,16 +161,16 @@ class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) TOTAL = "Total" COUNT = "Count" -class MetricCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric category. - """ + +class MetricCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric category.""" CAPACITY = "Capacity" TRANSACTION = "Transaction" -class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric units. - """ + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric units.""" NOT_SPECIFIED = "NotSpecified" PERCENT = "Percent" @@ -196,52 +181,52 @@ class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BYTES_PER_SECOND = "BytesPerSecond" COUNT_PER_SECOND = "CountPerSecond" -class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current monitoring status of the share. - """ + +class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current monitoring status of the share.""" ENABLED = "Enabled" DISABLED = "Disabled" -class MountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Mounting type. - """ + +class MountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Mounting type.""" VOLUME = "Volume" HOST_PATH = "HostPath" -class NetworkAdapterDHCPStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter has DHCP enabled. - """ + +class NetworkAdapterDHCPStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter has DHCP enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" -class NetworkAdapterRDMAStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is RDMA capable. - """ + +class NetworkAdapterRDMAStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is RDMA capable.""" INCAPABLE = "Incapable" CAPABLE = "Capable" -class NetworkAdapterStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is valid. - """ + +class NetworkAdapterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is valid.""" INACTIVE = "Inactive" ACTIVE = "Active" -class NetworkGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The network group. - """ + +class NetworkGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network group.""" NONE = "None" NON_RDMA = "NonRDMA" RDMA = "RDMA" -class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the individual node - """ + +class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the individual node.""" UNKNOWN = "Unknown" UP = "Up" @@ -249,9 +234,9 @@ class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REBOOTING = "Rebooting" SHUTTING_DOWN = "ShuttingDown" -class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the order as per the allowed status types. - """ + +class OrderState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the order as per the allowed status types.""" UNTRACKED = "Untracked" AWAITING_FULFILMENT = "AwaitingFulfilment" @@ -268,45 +253,47 @@ class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SHIPPED_BACK = "ShippedBack" COLLECTED_AT_MICROSOFT = "CollectedAtMicrosoft" -class PlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Host OS supported by the IoT role. - """ + +class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host OS supported by the IoT role.""" WINDOWS = "Windows" LINUX = "Linux" -class RoleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Role status. - """ + +class RoleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Role status.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RoleTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleTypes.""" IOT = "IOT" ASA = "ASA" FUNCTIONS = "Functions" COGNITIVE = "Cognitive" -class ShareAccessProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Access protocol to be used by the share. - """ + +class ShareAccessProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access protocol to be used by the share.""" SMB = "SMB" NFS = "NFS" -class ShareAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed on the share for this user. - """ + +class ShareAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed on the share for this user.""" CHANGE = "Change" READ = "Read" CUSTOM = "Custom" -class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the share. - """ + +class ShareStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the share.""" OFFLINE = "Offline" UNKNOWN = "Unknown" @@ -314,16 +301,16 @@ class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class SkuAvailability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Is SKU available - """ + +class SkuAvailability(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Is SKU available.""" AVAILABLE = "Available" UNAVAILABLE = "Unavailable" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku name. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku name.""" GATEWAY = "Gateway" EDGE = "Edge" @@ -339,43 +326,43 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): TCA_SMALL = "TCA_Small" GPU = "GPU" -class SkuRestrictionReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The SKU restriction reason. - """ + +class SkuRestrictionReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU restriction reason.""" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" QUOTA_ID = "QuotaId" -class SkuSignupOption(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Can the SKU be signed up.. - """ + +class SkuSignupOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Can the SKU be signed up..""" NONE = "None" AVAILABLE = "Available" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku tier. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku tier.""" STANDARD = "Standard" -class SkuVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Sku version. - """ + +class SkuVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sku version.""" STABLE = "Stable" PREVIEW = "Preview" -class SSLStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Signifies whether SSL needs to be enabled or not. - """ + +class SSLStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Signifies whether SSL needs to be enabled or not.""" ENABLED = "Enabled" DISABLED = "Disabled" -class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the storage account - """ + +class StorageAccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the storage account.""" OK = "OK" OFFLINE = "Offline" @@ -383,7 +370,9 @@ class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class TimeGrain(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TimeGrain.""" PT1_M = "PT1M" PT5_M = "PT5M" @@ -394,25 +383,25 @@ class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PT12_H = "PT12H" PT1_D = "PT1D" -class TriggerEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Trigger Kind. - """ + +class TriggerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trigger Kind.""" FILE_EVENT = "FileEvent" PERIODIC_TIMER_EVENT = "PeriodicTimerEvent" -class UpdateOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current update operation. - """ + +class UpdateOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current update operation.""" NONE = "None" SCAN = "Scan" DOWNLOAD = "Download" INSTALL = "Install" -class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current stage of the update operation. - """ + +class UpdateOperationStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current stage of the update operation.""" UNKNOWN = "Unknown" INITIAL = "Initial" @@ -432,9 +421,9 @@ class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESCAN_COMPLETE = "RescanComplete" RESCAN_FAILED = "RescanFailed" -class UserType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of the user. - """ + +class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the user.""" SHARE = "Share" LOCAL_MANAGEMENT = "LocalManagement" diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_models.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_models.py deleted file mode 100644 index 030d1bdf21d8..000000000000 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_models.py +++ /dev/null @@ -1,3657 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class Address(msrest.serialization.Model): - """The shipping address of the customer. - - All required parameters must be populated in order to send to Azure. - - :param address_line1: Required. The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: Required. The postal code. - :type postal_code: str - :param city: Required. The city name. - :type city: str - :param state: Required. The state name. - :type state: str - :param country: Required. The country name. - :type country: str - """ - - _validation = { - 'address_line1': {'required': True}, - 'postal_code': {'required': True}, - 'city': {'required': True}, - 'state': {'required': True}, - 'country': {'required': True}, - } - - _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Address, self).__init__(**kwargs) - self.address_line1 = kwargs['address_line1'] - self.address_line2 = kwargs.get('address_line2', None) - self.address_line3 = kwargs.get('address_line3', None) - self.postal_code = kwargs['postal_code'] - self.city = kwargs['city'] - self.state = kwargs['state'] - self.country = kwargs['country'] - - -class ARMBaseModel(msrest.serialization.Model): - """Represents the base class for all object models. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Alert(ARMBaseModel): - """Alert on the data box edge/gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar title: Alert title. - :vartype title: str - :ivar alert_type: Alert type. - :vartype alert_type: str - :ivar appeared_at_date_time: UTC time when the alert appeared. - :vartype appeared_at_date_time: ~datetime.datetime - :ivar recommendation: Alert recommendation. - :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", - "Critical". - :vartype severity: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AlertSeverity - :ivar error_details: Error details of the alert. - :vartype error_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AlertErrorDetails - :ivar detailed_information: Alert details. - :vartype detailed_information: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) - self.title = None - self.alert_type = None - self.appeared_at_date_time = None - self.recommendation = None - self.severity = None - self.error_details = None - self.detailed_information = None - - -class AlertErrorDetails(msrest.serialization.Model): - """Error details for the alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code. - :vartype error_code: str - :ivar error_message: Error Message. - :vartype error_message: str - :ivar occurrences: Number of occurrences. - :vartype occurrences: int - """ - - _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) - self.error_code = None - self.error_message = None - self.occurrences = None - - -class AlertList(msrest.serialization.Model): - """Collection of alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Alert] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class AsymmetricEncryptedSecret(msrest.serialization.Model): - """Represent the secrets intended for encryption with asymmetric key pair. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the - value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.EncryptionAlgorithm - """ - - _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) - self.value = kwargs['value'] - self.encryption_cert_thumbprint = kwargs.get('encryption_cert_thumbprint', None) - self.encryption_algorithm = kwargs['encryption_algorithm'] - - -class Authentication(msrest.serialization.Model): - """Authentication mechanism for IoT devices. - - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SymmetricKey - """ - - _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, - } - - def __init__( - self, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) - self.symmetric_key = kwargs.get('symmetric_key', None) - - -class AzureContainerInfo(msrest.serialization.Model): - """Azure container mapping of the endpoint. - - All required parameters must be populated in order to send to Azure. - - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AzureContainerDataFormat - """ - - _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, - } - - _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) - self.storage_account_credential_id = kwargs['storage_account_credential_id'] - self.container_name = kwargs['container_name'] - self.data_format = kwargs['data_format'] - - -class BandwidthSchedule(ARMBaseModel): - """The bandwidth schedule details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DayOfWeek] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) - self.start = kwargs['start'] - self.stop = kwargs['stop'] - self.rate_in_mbps = kwargs['rate_in_mbps'] - self.days = kwargs['days'] - - -class BandwidthSchedulesList(msrest.serialization.Model): - """The collection of bandwidth schedules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of bandwidth schedules. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ClientAccessRight(msrest.serialization.Model): - """The mapping between a particular client IP and the type of access client has on the NFS share. - - All required parameters must be populated in order to send to Azure. - - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ClientPermissionType - """ - - _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, - } - - _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) - self.client = kwargs['client'] - self.access_permission = kwargs['access_permission'] - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class ContactDetails(msrest.serialization.Model): - """Contains all the contact details of the customer. - - All required parameters must be populated in order to send to Azure. - - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] - """ - - _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) - self.contact_person = kwargs['contact_person'] - self.company_name = kwargs['company_name'] - self.phone = kwargs['phone'] - self.email_list = kwargs['email_list'] - - -class Container(ARMBaseModel): - """Represents a container on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". - :vartype container_status: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AzureContainerDataFormat - :ivar refresh_details: Details of the refresh job on this container. - :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RefreshDetails - :ivar created_date_time: The UTC time when container got created. - :vartype created_date_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Container, self).__init__(**kwargs) - self.container_status = None - self.data_format = kwargs['data_format'] - self.refresh_details = None - self.created_date_time = None - - -class ContainerList(msrest.serialization.Model): - """Collection of all the containers on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of containers. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevice(ARMBaseModel): - """The Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure - geographical region (for example, West US, East US, or Southeast Asia). The geographical region - of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDeviceStatus - :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. - :vartype serial_number: str - :param description: The Description of the Data Box Edge/Gateway device. - :type description: str - :param model_description: The description of the Data Box Edge/Gateway device model. - :type model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". - :vartype device_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DeviceType - :param friendly_name: The Data Box Edge/Gateway device name. - :type friendly_name: str - :ivar culture: The Data Box Edge/Gateway device culture. - :vartype culture: str - :ivar device_model: The Data Box Edge/Gateway device model. - :vartype device_model: str - :ivar device_software_version: The Data Box Edge/Gateway device software version. - :vartype device_software_version: str - :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long - :ivar time_zone: The Data Box Edge/Gateway device timezone. - :vartype time_zone: str - :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). - :vartype device_hcs_version: str - :ivar configured_role_types: Type of compute roles configured. - :vartype configured_role_types: list[str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleTypes] - :ivar node_count: The number of nodes in the cluster. - :vartype node_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'serial_number': {'readonly': True}, - 'device_type': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - self.etag = kwargs.get('etag', None) - self.data_box_edge_device_status = kwargs.get('data_box_edge_device_status', None) - self.serial_number = None - self.description = kwargs.get('description', None) - self.model_description = kwargs.get('model_description', None) - self.device_type = None - self.friendly_name = kwargs.get('friendly_name', None) - self.culture = None - self.device_model = None - self.device_software_version = None - self.device_local_capacity = None - self.time_zone = None - self.device_hcs_version = None - self.configured_role_types = None - self.node_count = None - - -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): - """The extended Info of the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to - encrypt any secret. - :type encryption_key: str - :ivar resource_key: The Resource ID of the Resource. - :vartype resource_key: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) - self.encryption_key_thumbprint = kwargs.get('encryption_key_thumbprint', None) - self.encryption_key = kwargs.get('encryption_key', None) - self.resource_key = None - - -class DataBoxEdgeDeviceList(msrest.serialization.Model): - """The collection of Data Box Edge/Gateway devices. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Data Box Edge/Gateway devices. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevicePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device patch. - - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class DataBoxEdgeSku(msrest.serialization.Model): - """The Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Large", "TCA_Small", "GPU". - :vartype name: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuName - :ivar kind: The Sku kind. - :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". - :vartype tier: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuTier - :ivar size: The Sku kind. - :vartype size: str - :ivar family: The Sku family. - :vartype family: str - :ivar locations: Availability of the Sku for the region. - :vartype locations: list[str] - :ivar api_versions: The API versions in which Sku is available. - :vartype api_versions: list[str] - :ivar location_info: Availability of the Sku for the location/zone/site. - :vartype location_info: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuLocationInfo] - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuCost] - :ivar restrictions: Restriction info of the SKU. - :vartype restrictions: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuRestriction] - :ivar signup_option: Can the SKU be signed up.. Possible values include: "None", "Available". - :vartype signup_option: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuSignupOption - :ivar version: Sku version. Possible values include: "Stable", "Preview". - :vartype version: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuVersion - :ivar availability: Is SKU available. Possible values include: "Available", "Unavailable". - :vartype availability: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuAvailability - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'restrictions': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'restrictions': {'key': 'restrictions', 'type': '[SkuRestriction]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) - self.resource_type = None - self.name = None - self.kind = None - self.tier = None - self.size = None - self.family = None - self.locations = None - self.api_versions = None - self.location_info = None - self.costs = None - self.restrictions = None - self.signup_option = None - self.version = None - self.availability = None - - -class DataBoxEdgeSkuList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceType Sku. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Trigger(ARMBaseModel): - """Trigger details. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerEventType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } - - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.kind = 'Trigger' # type: str - - -class FileEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class FileSourceInfo(msrest.serialization.Model): - """File source details. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. File share ID. - :type share_id: str - """ - - _validation = { - 'share_id': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - - -class ImageRepositoryCredential(msrest.serialization.Model): - """Image repository credential. - - All required parameters must be populated in order to send to Azure. - - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, - } - - _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageRepositoryCredential, self).__init__(**kwargs) - self.image_repository_url = kwargs['image_repository_url'] - self.user_name = kwargs['user_name'] - self.password = kwargs.get('password', None) - - -class IoTDeviceInfo(msrest.serialization.Model): - """Metadata of IoT device/IoT Edge device to be configured. - - All required parameters must be populated in order to send to Azure. - - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Authentication - """ - - _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) - self.device_id = kwargs['device_id'] - self.io_t_host_hub = kwargs['io_t_host_hub'] - self.io_t_host_hub_id = kwargs.get('io_t_host_hub_id', None) - self.authentication = kwargs.get('authentication', None) - - -class IoTEdgeAgentInfo(msrest.serialization.Model): - """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. - - All required parameters must be populated in order to send to Azure. - - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ImageRepositoryCredential - """ - - _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, - } - - _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) - self.image_name = kwargs['image_name'] - self.tag = kwargs['tag'] - self.image_repository = kwargs.get('image_repository', None) - - -class Role(ARMBaseModel): - """Compute role. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: IoTRole. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleTypes - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'IOT': 'IoTRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str - - -class IoTRole(Role): - """Compute role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleTypes - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", - "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot - runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.HostPlatformType - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'host_platform_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.io_t_device_details = kwargs.get('io_t_device_details', None) - self.io_t_edge_device_details = kwargs.get('io_t_edge_device_details', None) - self.share_mappings = kwargs.get('share_mappings', None) - self.io_t_edge_agent_info = kwargs.get('io_t_edge_agent_info', None) - self.host_platform_type = None - self.role_status = kwargs.get('role_status', None) - - -class Ipv4Config(msrest.serialization.Model): - """Details related to the IPv4 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv4 address of the network adapter. - :vartype ip_address: str - :ivar subnet: The IPv4 subnet of the network adapter. - :vartype subnet: str - :ivar gateway: The IPv4 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) - self.ip_address = None - self.subnet = None - self.gateway = None - - -class Ipv6Config(msrest.serialization.Model): - """Details related to the IPv6 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv6 address of the network adapter. - :vartype ip_address: str - :ivar prefix_length: The IPv6 prefix of the network adapter. - :vartype prefix_length: int - :ivar gateway: The IPv6 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) - self.ip_address = None - self.prefix_length = None - self.gateway = None - - -class Job(msrest.serialization.Model): - """A device job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The name of the object. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.JobStatus - :ivar start_time: The UTC date and time at which the job started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The UTC date and time at which the job completed. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: The percentage of the job that is complete. - :vartype percent_complete: int - :ivar error: The error details. - :vartype error: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer". - :vartype job_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", - "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", - "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". - :vartype current_stage: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UpdateOperationStage - :ivar download_progress: The download progress. - :vartype download_progress: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UpdateDownloadProgress - :ivar install_progress: The install progress. - :vartype install_progress: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UpdateInstallProgress - :ivar total_refresh_errors: Total number of errors encountered during the refresh process. - :vartype total_refresh_errors: int - :ivar error_manifest_file: Local share/remote container relative path to the error manifest - file of the refresh. - :vartype error_manifest_file: str - :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. - :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_time = None - self.end_time = None - self.percent_complete = None - self.error = None - self.job_type = None - self.current_stage = None - self.download_progress = None - self.install_progress = None - self.total_refresh_errors = None - self.error_manifest_file = None - self.refreshed_entity_id = None - self.folder = kwargs.get('folder', None) - - -class JobErrorDetails(msrest.serialization.Model): - """The job error information containing the list of job errors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_details: The error details. - :vartype error_details: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.JobErrorItem] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) - self.error_details = None - self.code = None - self.message = None - - -class JobErrorItem(msrest.serialization.Model): - """The job error items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendations: The recommended actions. - :vartype recommendations: list[str] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) - self.recommendations = None - self.code = None - self.message = None - - -class MetricDimensionV1(msrest.serialization.Model): - """Metric Dimension v1. - - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimensionV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecificationV1(msrest.serialization.Model): - """Metric specification version 1. - - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricAggregationType] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.dimensions = kwargs.get('dimensions', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - - -class MountPointMap(msrest.serialization.Model): - """The share mount point. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str - :ivar role_id: ID of the role to which share is mounted. - :vartype role_id: str - :ivar mount_point: Mount point for the share. - :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". - :vartype mount_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive". - :vartype role_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleTypes - """ - - _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.role_id = None - self.mount_point = None - self.mount_type = None - self.role_type = None - - -class NetworkAdapter(msrest.serialization.Model): - """Represents the networkAdapter on a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar adapter_id: Instance ID of network adapter. - :vartype adapter_id: str - :ivar adapter_position: Hardware position of network adapter. - :vartype adapter_position: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapterPosition - :ivar index: Logical index of the adapter. - :vartype index: int - :ivar node_id: Node ID of the network adapter. - :vartype node_id: str - :ivar network_adapter_name: Network adapter name. - :vartype network_adapter_name: str - :ivar label: Hardware label for the adapter. - :vartype label: str - :ivar mac_address: MAC address. - :vartype mac_address: str - :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". - :vartype status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapterDHCPStatus - :ivar ipv4_configuration: The IPv4 configuration of the network adapter. - :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Ipv4Config - :ivar ipv6_configuration: The IPv6 configuration of the network adapter. - :vartype ipv6_configuration: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Ipv6Config - :ivar ipv6_link_local_address: The IPv6 local address. - :vartype ipv6_link_local_address: str - :ivar dns_servers: The list of DNS Servers of the device. - :vartype dns_servers: list[str] - """ - - _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) - self.adapter_id = None - self.adapter_position = None - self.index = None - self.node_id = None - self.network_adapter_name = None - self.label = None - self.mac_address = None - self.link_speed = None - self.status = None - self.rdma_status = kwargs.get('rdma_status', None) - self.dhcp_status = kwargs.get('dhcp_status', None) - self.ipv4_configuration = None - self.ipv6_configuration = None - self.ipv6_link_local_address = None - self.dns_servers = None - - -class NetworkAdapterPosition(msrest.serialization.Model): - """The network adapter position. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". - :vartype network_group: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkGroup - :ivar port: The port. - :vartype port: int - """ - - _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, - } - - _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) - self.network_group = None - self.port = None - - -class NetworkSettings(ARMBaseModel): - """The network settings of a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar network_adapters: The network adapter list on the device. - :vartype network_adapters: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapter] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) - self.network_adapters = None - - -class Node(ARMBaseModel): - """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) - self.node_status = None - self.node_chassis_serial_number = None - self.node_serial_number = None - self.node_display_name = None - self.node_friendly_software_version = None - self.node_hcs_version = None - self.node_instance_id = None - - -class NodeList(msrest.serialization.Model): - """Collection of Nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Nodes. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Node] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) - self.value = None - - -class Operation(msrest.serialization.Model): - """Operations. - - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ServiceSpecification - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationDisplay(msrest.serialization.Model): - """Operation display properties. - - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str - """ - - _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 = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """The list of operations used for the discovery of available provider operations. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class Order(ARMBaseModel): - """The order details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Address - :param current_status: Current status of the order. - :type current_status: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderStatus - :ivar order_history: List of status changes in the order. - :vartype order_history: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderStatus] - :ivar serial_number: Serial number of the device. - :vartype serial_number: str - :ivar delivery_tracking_info: Tracking information for the package delivered to the customer - whether it has an original or a replacement device. - :vartype delivery_tracking_info: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.TrackingInfo] - :ivar return_tracking_info: Tracking information for the package returned from the customer - whether it has an original or a replacement device. - :vartype return_tracking_info: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.TrackingInfo] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(Order, self).__init__(**kwargs) - self.contact_information = kwargs.get('contact_information', None) - self.shipping_address = kwargs.get('shipping_address', None) - self.current_status = kwargs.get('current_status', None) - self.order_history = None - self.serial_number = None - self.delivery_tracking_info = None - self.return_tracking_info = None - - -class OrderList(msrest.serialization.Model): - """List of order entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of orders. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OrderStatus(msrest.serialization.Model): - """Represents a single status change. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft". - :type status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderState - :ivar update_date_time: Time of status update. - :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str - :ivar additional_order_details: Dictionary to hold generic information which is not stored - by the already existing properties. - :vartype additional_order_details: dict[str, str] - """ - - _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'additional_order_details': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) - self.status = kwargs['status'] - self.update_date_time = None - self.comments = kwargs.get('comments', None) - self.additional_order_details = None - - -class PeriodicTimerEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class PeriodicTimerSourceInfo(msrest.serialization.Model): - """Periodic timer event source. - - All required parameters must be populated in order to send to Azure. - - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str - """ - - _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) - self.start_time = kwargs['start_time'] - self.schedule = kwargs['schedule'] - self.topic = kwargs.get('topic', None) - - -class RefreshDetails(msrest.serialization.Model): - """Fields for tracking refresh job on the share or container. - - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or - container, this field indicates the ARM resource ID of that job. The field is empty if no job - is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh - job on this particular share or container, if any. This could be a failed job or a successful - job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or - container,if any. This could be a failed job or a successful job. - :type last_job: str - """ - - _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RefreshDetails, self).__init__(**kwargs) - self.in_progress_refresh_job_id = kwargs.get('in_progress_refresh_job_id', None) - self.last_completed_refresh_job_time_in_utc = kwargs.get('last_completed_refresh_job_time_in_utc', None) - self.error_manifest_file = kwargs.get('error_manifest_file', None) - self.last_job = kwargs.get('last_job', None) - - -class ResourceTypeSku(msrest.serialization.Model): - """SkuInformation object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Large", "TCA_Small", "GPU". - :vartype name: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuName - :ivar kind: The Sku kind. - :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". - :vartype tier: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuTier - :ivar family: The Sku family. - :vartype family: str - :ivar locations: Availability of the SKU for the region. - :vartype locations: list[str] - :ivar api_versions: The API versions in which SKU is available. - :vartype api_versions: list[str] - :ivar location_info: Availability of the SKU for the location/zone. - :vartype location_info: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuLocationInfo] - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuCost] - :ivar restrictions: Restrictions of the SKU availability. - :vartype restrictions: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuRestriction] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'restrictions': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'restrictions': {'key': 'restrictions', 'type': '[SkuRestriction]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) - self.resource_type = None - self.name = None - self.kind = None - self.tier = None - self.family = None - self.locations = None - self.api_versions = None - self.location_info = None - self.costs = None - self.restrictions = None - - -class RoleList(msrest.serialization.Model): - """Collection of all the roles on the Data Box Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RoleSinkInfo(msrest.serialization.Model): - """Compute role against which events will be raised. - - All required parameters must be populated in order to send to Azure. - - :param role_id: Required. Compute role ID. - :type role_id: str - """ - - _validation = { - 'role_id': {'required': True}, - } - - _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) - self.role_id = kwargs['role_id'] - - -class SecuritySettings(ARMBaseModel): - """The security settings of a device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) - self.device_admin_password = kwargs['device_admin_password'] - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification. - - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricSpecificationV1] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Share(ARMBaseModel): - """Represents a share on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share - (required for SMB protocol). - :type user_access_rights: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the - share(required for NFS protocol). - :type client_access_rights: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RefreshDetails - :ivar share_mappings: Share mount point to the role. - :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Share, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.share_status = kwargs['share_status'] - self.monitoring_status = kwargs['monitoring_status'] - self.azure_container_info = kwargs.get('azure_container_info', None) - self.access_protocol = kwargs['access_protocol'] - self.user_access_rights = kwargs.get('user_access_rights', None) - self.client_access_rights = kwargs.get('client_access_rights', None) - self.refresh_details = kwargs.get('refresh_details', None) - self.share_mappings = None - self.data_policy = kwargs.get('data_policy', None) - - -class ShareAccessRight(msrest.serialization.Model): - """Specifies the mapping between this particular user and the type of access he has on shares on this device. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessType - """ - - _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.access_type = kwargs['access_type'] - - -class ShareList(msrest.serialization.Model): - """Collection of all the shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of shares. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Sku(msrest.serialization.Model): - """The SKU type. - - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Large", "TCA_Small", "GPU". - :type name: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuTier - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - - -class SKUCapability(msrest.serialization.Model): - """The capabilities of the SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The capability name. - :vartype name: str - :ivar value: The capability value. - :vartype value: str - """ - - _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SKUCapability, self).__init__(**kwargs) - self.name = None - self.value = None - - -class SkuCost(msrest.serialization.Model): - """The metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The cost quantity. - :vartype quantity: long - :ivar extended_unit: The extended unit. - :vartype extended_unit: str - """ - - _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, - } - - _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) - self.meter_id = None - self.quantity = None - self.extended_unit = None - - -class SkuInformation(msrest.serialization.Model): - """Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The resource type. - :vartype resource_type: str - :ivar name: The sku name. - :vartype name: str - :ivar tier: The sku tier. - :vartype tier: str - :ivar kind: The sku kind. - :vartype kind: str - :ivar size: The sku size. - :vartype size: str - :ivar family: The sku family. - :vartype family: str - :ivar locations: The locations where Sku is available. - :vartype locations: list[str] - :ivar location_info: The locations where Sku is available with zones and sites info. - :vartype location_info: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuLocationInfo] - :ivar required_quota_ids: The required quotaIds for the sku to be available. - :vartype required_quota_ids: list[str] - :ivar required_features: The required features for the sku to be available. - :vartype required_features: list[str] - :ivar costs: The cost of the SKU. - :vartype costs: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuCost] - :ivar capabilities: The capabilities of the SKU. - :vartype capabilities: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SKUCapability] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, - 'costs': {'readonly': True}, - 'capabilities': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) - self.resource_type = None - self.name = None - self.tier = None - self.kind = None - self.size = None - self.family = None - self.locations = None - self.location_info = None - self.required_quota_ids = None - self.required_features = None - self.costs = None - self.capabilities = None - - -class SkuInformationList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceType Sku. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ResourceTypeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SkuLocationInfo(msrest.serialization.Model): - """The location info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The location. - :vartype location: str - :ivar zones: The zones. - :vartype zones: list[str] - :ivar sites: The sites. - :vartype sites: list[str] - """ - - _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) - self.location = None - self.zones = None - self.sites = None - - -class SkuRestriction(msrest.serialization.Model): - """The restrictions because of which SKU cannot be used. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the restriction. - :vartype type: str - :ivar values: The locations where sku is restricted. - :vartype values: list[str] - :ivar reason_code: The SKU restriction reason. Possible values include: - "NotAvailableForSubscription", "QuotaId". - :vartype reason_code: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuRestrictionReasonCode - :ivar restriction_info: Restriction of the SKU for the location/zone. - :vartype restriction_info: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuRestrictionInfo - """ - - _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, - 'reason_code': {'readonly': True}, - 'restriction_info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'SkuRestrictionInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuRestriction, self).__init__(**kwargs) - self.type = None - self.values = None - self.reason_code = None - self.restriction_info = None - - -class SkuRestrictionInfo(msrest.serialization.Model): - """The restriction info with locations and zones. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar locations: The locations. - :vartype locations: list[str] - :ivar zones: The zones. - :vartype zones: list[str] - """ - - _validation = { - 'locations': {'readonly': True}, - 'zones': {'readonly': True}, - } - - _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuRestrictionInfo, self).__init__(**kwargs) - self.locations = None - self.zones = None - - -class StorageAccount(ARMBaseModel): - """Represents a Storage Account on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountStatus - :param data_policy: Data policy of the storage Account. Possible values include: "Cloud", - "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str - :ivar blob_endpoint: BlobEndpoint of Storage Account. - :vartype blob_endpoint: str - :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy - set to Cloud. - :vartype container_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccount, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.storage_account_status = kwargs.get('storage_account_status', None) - self.data_policy = kwargs.get('data_policy', None) - self.storage_account_credential_id = kwargs.get('storage_account_credential_id', None) - self.blob_endpoint = None - self.container_count = None - - -class StorageAccountCredential(ARMBaseModel): - """The storage account credential. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredential, self).__init__(**kwargs) - self.alias = kwargs['alias'] - self.user_name = kwargs.get('user_name', None) - self.account_key = kwargs.get('account_key', None) - self.connection_string = kwargs.get('connection_string', None) - self.ssl_status = kwargs['ssl_status'] - self.blob_domain_name = kwargs.get('blob_domain_name', None) - self.account_type = kwargs['account_type'] - self.storage_account_id = kwargs.get('storage_account_id', None) - - -class StorageAccountCredentialList(msrest.serialization.Model): - """The collection of storage account credentials. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class StorageAccountList(msrest.serialization.Model): - """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of storageAccounts. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SymmetricKey(msrest.serialization.Model): - """Symmetric key for authentication. - - :param connection_string: Connection string based on the symmetric key. - :type connection_string: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret - """ - - _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) - self.connection_string = kwargs.get('connection_string', None) - - -class TrackingInfo(msrest.serialization.Model): - """Tracking courier information. - - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str - """ - - _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackingInfo, self).__init__(**kwargs) - self.serial_number = kwargs.get('serial_number', None) - self.carrier_name = kwargs.get('carrier_name', None) - self.tracking_id = kwargs.get('tracking_id', None) - self.tracking_url = kwargs.get('tracking_url', None) - - -class TriggerList(msrest.serialization.Model): - """Collection of all trigger on the data box edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of triggers. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UpdateDownloadProgress(msrest.serialization.Model): - """Details about the download progress of update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". - :vartype download_phase: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DownloadPhase - :ivar percent_complete: Percentage of completion. - :vartype percent_complete: int - :ivar total_bytes_to_download: Total bytes to download. - :vartype total_bytes_to_download: float - :ivar total_bytes_downloaded: Total bytes downloaded. - :vartype total_bytes_downloaded: float - :ivar number_of_updates_to_download: Number of updates to download. - :vartype number_of_updates_to_download: int - :ivar number_of_updates_downloaded: Number of updates downloaded. - :vartype number_of_updates_downloaded: int - """ - - _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, - } - - _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) - self.download_phase = None - self.percent_complete = None - self.total_bytes_to_download = None - self.total_bytes_downloaded = None - self.number_of_updates_to_download = None - self.number_of_updates_downloaded = None - - -class UpdateInstallProgress(msrest.serialization.Model): - """Progress details during installation of updates. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar percent_complete: Percentage completed. - :vartype percent_complete: int - :ivar number_of_updates_to_install: Number of updates to install. - :vartype number_of_updates_to_install: int - :ivar number_of_updates_installed: Number of updates installed. - :vartype number_of_updates_installed: int - """ - - _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, - } - - _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) - self.percent_complete = None - self.number_of_updates_to_install = None - self.number_of_updates_installed = None - - -class UpdateSummary(ARMBaseModel): - """Details about ongoing updates and availability of updates on the device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed - (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime - :ivar last_completed_download_job_date_time: The time when the last Download job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_download_job_date_time: ~datetime.datetime - :ivar last_completed_install_job_date_time: The time when the last Install job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_install_job_date_time: ~datetime.datetime - :ivar total_number_of_updates_available: The number of updates available for the current device - version as per the last device scan. - :vartype total_number_of_updates_available: int - :ivar total_number_of_updates_pending_download: The total number of items pending download. - :vartype total_number_of_updates_pending_download: int - :ivar total_number_of_updates_pending_install: The total number of items pending install. - :vartype total_number_of_updates_pending_install: int - :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". - :vartype ongoing_update_operation: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UpdateOperation - :ivar in_progress_download_job_id: The job ID of the download job in progress. - :vartype in_progress_download_job_id: str - :ivar in_progress_install_job_id: The job ID of the install job in progress. - :vartype in_progress_install_job_id: str - :ivar in_progress_download_job_started_date_time: The time when the currently running download - (if any) started. - :vartype in_progress_download_job_started_date_time: ~datetime.datetime - :ivar in_progress_install_job_started_date_time: The time when the currently running install - (if any) started. - :vartype in_progress_install_job_started_date_time: ~datetime.datetime - :ivar update_titles: The list of updates available for install. - :vartype update_titles: list[str] - :ivar total_update_size_in_bytes: The total size of updates available for download in bytes. - :vartype total_update_size_in_bytes: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateSummary, self).__init__(**kwargs) - self.device_version_number = kwargs.get('device_version_number', None) - self.friendly_device_version_name = kwargs.get('friendly_device_version_name', None) - self.device_last_scanned_date_time = kwargs.get('device_last_scanned_date_time', None) - self.last_completed_scan_job_date_time = kwargs.get('last_completed_scan_job_date_time', None) - self.last_completed_download_job_date_time = None - self.last_completed_install_job_date_time = None - self.total_number_of_updates_available = None - self.total_number_of_updates_pending_download = None - self.total_number_of_updates_pending_install = None - self.reboot_behavior = None - self.ongoing_update_operation = None - self.in_progress_download_job_id = None - self.in_progress_install_job_id = None - self.in_progress_download_job_started_date_time = None - self.in_progress_install_job_started_date_time = None - self.update_titles = None - self.total_update_size_in_bytes = None - - -class UploadCertificateRequest(msrest.serialization.Model): - """The upload certificate request. - - All required parameters must be populated in order to send to Azure. - - :param authentication_type: The authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type authentication_type: str or - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str - """ - - _validation = { - 'certificate': {'required': True}, - } - - _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) - self.authentication_type = kwargs.get('authentication_type', None) - self.certificate = kwargs['certificate'] - - -class UploadCertificateResponse(msrest.serialization.Model): - """The upload registration certificate response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param auth_type: Specifies authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AuthenticationType - :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. - :vartype resource_id: str - :ivar aad_authority: Azure Active Directory tenant authority. - :vartype aad_authority: str - :ivar aad_tenant_id: Azure Active Directory tenant ID. - :vartype aad_tenant_id: str - :ivar service_principal_client_id: Azure Active Directory service principal client ID. - :vartype service_principal_client_id: str - :ivar service_principal_object_id: Azure Active Directory service principal object ID. - :vartype service_principal_object_id: str - :ivar azure_management_endpoint_audience: The azure management endpoint audience. - :vartype azure_management_endpoint_audience: str - :ivar aad_audience: Identifier of the target resource that is the recipient of the requested - token. - :vartype aad_audience: str - """ - - _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, - } - - _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) - self.auth_type = kwargs.get('auth_type', None) - self.resource_id = None - self.aad_authority = None - self.aad_tenant_id = None - self.service_principal_client_id = None - self.service_principal_object_id = None - self.azure_management_endpoint_audience = None - self.aad_audience = None - - -class User(ARMBaseModel): - """Represents a user who has access to one or more shares on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encrypted_password: The password details. - :type encrypted_password: - ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret - :ivar share_access_rights: List of shares that the user has rights on. This field should not be - specified during user creation. - :vartype share_access_rights: - list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessRight] - :param user_type: Required. Type of the user. Possible values include: "Share", - "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UserType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_access_rights': {'readonly': True}, - 'user_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.encrypted_password = kwargs.get('encrypted_password', None) - self.share_access_rights = None - self.user_type = kwargs['user_type'] - - -class UserAccessRight(msrest.serialization.Model): - """The mapping between a particular user and the access type on the SMB share. - - All required parameters must be populated in order to send to Azure. - - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessType - """ - - _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) - self.user_id = kwargs['user_id'] - self.access_type = kwargs['access_type'] - - -class UserList(msrest.serialization.Model): - """Collection of users. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of users. - :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) - self.value = None - self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_models_py3.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_models_py3.py index e32e2df99e08..2f23df8cbd52 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_models_py3.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,50 +8,52 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._data_box_edge_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Address(msrest.serialization.Model): +class Address(_serialization.Model): """The shipping address of the customer. All required parameters must be populated in order to send to Azure. - :param address_line1: Required. The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: Required. The postal code. - :type postal_code: str - :param city: Required. The city name. - :type city: str - :param state: Required. The state name. - :type state: str - :param country: Required. The country name. - :type country: str + :ivar address_line1: The address line1. Required. + :vartype address_line1: str + :ivar address_line2: The address line2. + :vartype address_line2: str + :ivar address_line3: The address line3. + :vartype address_line3: str + :ivar postal_code: The postal code. Required. + :vartype postal_code: str + :ivar city: The city name. Required. + :vartype city: str + :ivar state: The state name. Required. + :vartype state: str + :ivar country: The country name. Required. + :vartype country: str """ _validation = { - 'address_line1': {'required': True}, - 'postal_code': {'required': True}, - 'city': {'required': True}, - 'state': {'required': True}, - 'country': {'required': True}, + "address_line1": {"required": True}, + "postal_code": {"required": True}, + "city": {"required": True}, + "state": {"required": True}, + "country": {"required": True}, } _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, + "address_line1": {"key": "addressLine1", "type": "str"}, + "address_line2": {"key": "addressLine2", "type": "str"}, + "address_line3": {"key": "addressLine3", "type": "str"}, + "postal_code": {"key": "postalCode", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "country": {"key": "country", "type": "str"}, } def __init__( @@ -65,7 +68,23 @@ def __init__( address_line3: Optional[str] = None, **kwargs ): - super(Address, self).__init__(**kwargs) + """ + :keyword address_line1: The address line1. Required. + :paramtype address_line1: str + :keyword address_line2: The address line2. + :paramtype address_line2: str + :keyword address_line3: The address line3. + :paramtype address_line3: str + :keyword postal_code: The postal code. Required. + :paramtype postal_code: str + :keyword city: The city name. Required. + :paramtype city: str + :keyword state: The state name. Required. + :paramtype state: str + :keyword country: The country name. Required. + :paramtype country: str + """ + super().__init__(**kwargs) self.address_line1 = address_line1 self.address_line2 = address_line2 self.address_line3 = address_line3 @@ -75,7 +94,7 @@ def __init__( self.country = country -class ARMBaseModel(msrest.serialization.Model): +class ARMBaseModel(_serialization.Model): """Represents the base class for all object models. Variables are only populated by the server, and will be ignored when sending a request. @@ -89,22 +108,20 @@ class ARMBaseModel(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -129,7 +146,7 @@ class Alert(ARMBaseModel): :vartype appeared_at_date_time: ~datetime.datetime :ivar recommendation: Alert recommendation. :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", + :ivar severity: Severity of the alert. Known values are: "Informational", "Warning", and "Critical". :vartype severity: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AlertSeverity :ivar error_details: Error details of the alert. @@ -139,36 +156,34 @@ class Alert(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "title": {"readonly": True}, + "alert_type": {"readonly": True}, + "appeared_at_date_time": {"readonly": True}, + "recommendation": {"readonly": True}, + "severity": {"readonly": True}, + "error_details": {"readonly": True}, + "detailed_information": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "title": {"key": "properties.title", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "appeared_at_date_time": {"key": "properties.appearedAtDateTime", "type": "iso-8601"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "error_details": {"key": "properties.errorDetails", "type": "AlertErrorDetails"}, + "detailed_information": {"key": "properties.detailedInformation", "type": "{str}"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.title = None self.alert_type = None self.appeared_at_date_time = None @@ -178,7 +193,7 @@ def __init__( self.detailed_information = None -class AlertErrorDetails(msrest.serialization.Model): +class AlertErrorDetails(_serialization.Model): """Error details for the alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -192,28 +207,26 @@ class AlertErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, + "error_code": {"readonly": True}, + "error_message": {"readonly": True}, + "occurrences": {"readonly": True}, } _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "occurrences": {"key": "occurrences", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_code = None self.error_message = None self.occurrences = None -class AlertList(msrest.serialization.Model): +class AlertList(_serialization.Model): """Collection of alerts. Variables are only populated by the server, and will be ignored when sending a request. @@ -225,113 +238,121 @@ class AlertList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class AsymmetricEncryptedSecret(msrest.serialization.Model): +class AsymmetricEncryptedSecret(_serialization.Model): """Represent the secrets intended for encryption with asymmetric key pair. All required parameters must be populated in order to send to Azure. - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + :ivar value: The value of the secret. Required. + :vartype value: str + :ivar encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or + :vartype encryption_cert_thumbprint: str + :ivar encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values are: + "None", "AES256", and "RSAES_PKCS1_v_1_5". + :vartype encryption_algorithm: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.EncryptionAlgorithm """ _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, + "value": {"required": True}, + "encryption_algorithm": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "encryption_cert_thumbprint": {"key": "encryptionCertThumbprint", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, } def __init__( self, *, value: str, - encryption_algorithm: Union[str, "EncryptionAlgorithm"], + encryption_algorithm: Union[str, "_models.EncryptionAlgorithm"], encryption_cert_thumbprint: Optional[str] = None, **kwargs ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) + """ + :keyword value: The value of the secret. Required. + :paramtype value: str + :keyword encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :paramtype encryption_cert_thumbprint: str + :keyword encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values + are: "None", "AES256", and "RSAES_PKCS1_v_1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.EncryptionAlgorithm + """ + super().__init__(**kwargs) self.value = value self.encryption_cert_thumbprint = encryption_cert_thumbprint self.encryption_algorithm = encryption_algorithm -class Authentication(msrest.serialization.Model): +class Authentication(_serialization.Model): """Authentication mechanism for IoT devices. - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SymmetricKey + :ivar symmetric_key: Symmetric key for authentication. + :vartype symmetric_key: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SymmetricKey """ _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, + "symmetric_key": {"key": "symmetricKey", "type": "SymmetricKey"}, } - def __init__( - self, - *, - symmetric_key: Optional["SymmetricKey"] = None, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) + def __init__(self, *, symmetric_key: Optional["_models.SymmetricKey"] = None, **kwargs): + """ + :keyword symmetric_key: Symmetric key for authentication. + :paramtype symmetric_key: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SymmetricKey + """ + super().__init__(**kwargs) self.symmetric_key = symmetric_key -class AzureContainerInfo(msrest.serialization.Model): +class AzureContainerInfo(_serialization.Model): """Azure container mapping of the endpoint. All required parameters must be populated in order to send to Azure. - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or + :ivar storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :vartype storage_account_credential_id: str + :ivar container_name: Container name (Based on the data format specified, this represents the + name of Azure Files/Page blob/Block blob). Required. + :vartype container_name: str + :ivar data_format: Storage format used for the file represented by the share. Required. Known + values are: "BlockBlob", "PageBlob", and "AzureFile". + :vartype data_format: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AzureContainerDataFormat """ _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, + "storage_account_credential_id": {"required": True}, + "container_name": {"required": True}, + "data_format": {"required": True}, } _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, + "storage_account_credential_id": {"key": "storageAccountCredentialId", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "data_format": {"key": "dataFormat", "type": "str"}, } def __init__( @@ -339,10 +360,22 @@ def __init__( *, storage_account_credential_id: str, container_name: str, - data_format: Union[str, "AzureContainerDataFormat"], + data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs ): - super(AzureContainerInfo, self).__init__(**kwargs) + """ + :keyword storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :paramtype storage_account_credential_id: str + :keyword container_name: Container name (Based on the data format specified, this represents + the name of Azure Files/Page blob/Block blob). Required. + :paramtype container_name: str + :keyword data_format: Storage format used for the file represented by the share. Required. + Known values are: "BlockBlob", "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.storage_account_credential_id = storage_account_credential_id self.container_name = container_name self.data_format = data_format @@ -361,53 +394,57 @@ class BandwidthSchedule(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DayOfWeek] + :ivar start: The start time of the schedule in UTC. Required. + :vartype start: str + :ivar stop: The stop time of the schedule in UTC. Required. + :vartype stop: str + :ivar rate_in_mbps: The bandwidth rate in Mbps. Required. + :vartype rate_in_mbps: int + :ivar days: The days of the week when this schedule is applicable. Required. + :vartype days: list[str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DayOfWeek] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "start": {"required": True}, + "stop": {"required": True}, + "rate_in_mbps": {"required": True}, + "days": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "start": {"key": "properties.start", "type": "str"}, + "stop": {"key": "properties.stop", "type": "str"}, + "rate_in_mbps": {"key": "properties.rateInMbps", "type": "int"}, + "days": {"key": "properties.days", "type": "[str]"}, } def __init__( - self, - *, - start: str, - stop: str, - rate_in_mbps: int, - days: List[Union[str, "DayOfWeek"]], - **kwargs + self, *, start: str, stop: str, rate_in_mbps: int, days: List[Union[str, "_models.DayOfWeek"]], **kwargs ): - super(BandwidthSchedule, self).__init__(**kwargs) + """ + :keyword start: The start time of the schedule in UTC. Required. + :paramtype start: str + :keyword stop: The stop time of the schedule in UTC. Required. + :paramtype stop: str + :keyword rate_in_mbps: The bandwidth rate in Mbps. Required. + :paramtype rate_in_mbps: int + :keyword days: The days of the week when this schedule is applicable. Required. + :paramtype days: list[str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DayOfWeek] + """ + super().__init__(**kwargs) self.start = start self.stop = stop self.rate_in_mbps = rate_in_mbps self.days = days -class BandwidthSchedulesList(msrest.serialization.Model): +class BandwidthSchedulesList(_serialization.Model): """The collection of bandwidth schedules. Variables are only populated by the server, and will be ignored when sending a request. @@ -419,76 +456,76 @@ class BandwidthSchedulesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BandwidthSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ClientAccessRight(msrest.serialization.Model): +class ClientAccessRight(_serialization.Model): """The mapping between a particular client IP and the type of access client has on the NFS share. All required parameters must be populated in order to send to Azure. - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or + :ivar client: IP of the client. Required. + :vartype client: str + :ivar access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :vartype access_permission: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ClientPermissionType """ _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, + "client": {"required": True}, + "access_permission": {"required": True}, } _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - *, - client: str, - access_permission: Union[str, "ClientPermissionType"], - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) + "client": {"key": "client", "type": "str"}, + "access_permission": {"key": "accessPermission", "type": "str"}, + } + + def __init__(self, *, client: str, access_permission: Union[str, "_models.ClientPermissionType"], **kwargs): + """ + :keyword client: IP of the client. Required. + :paramtype client: str + :keyword access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :paramtype access_permission: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ClientPermissionType + """ + super().__init__(**kwargs) self.client = client self.access_permission = access_permission -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.CloudErrorBody] + :vartype message: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.CloudErrorBody] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -496,54 +533,66 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): - super(CloudErrorBody, self).__init__(**kwargs) + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.CloudErrorBody] + """ + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class ContactDetails(msrest.serialization.Model): +class ContactDetails(_serialization.Model): """Contains all the contact details of the customer. All required parameters must be populated in order to send to Azure. - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] + :ivar contact_person: The contact person name. Required. + :vartype contact_person: str + :ivar company_name: The name of the company. Required. + :vartype company_name: str + :ivar phone: The phone number. Required. + :vartype phone: str + :ivar email_list: The email list. Required. + :vartype email_list: list[str] """ _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, + "contact_person": {"required": True}, + "company_name": {"required": True}, + "phone": {"required": True}, + "email_list": {"required": True}, } _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - *, - contact_person: str, - company_name: str, - phone: str, - email_list: List[str], - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) + "contact_person": {"key": "contactPerson", "type": "str"}, + "company_name": {"key": "companyName", "type": "str"}, + "phone": {"key": "phone", "type": "str"}, + "email_list": {"key": "emailList", "type": "[str]"}, + } + + def __init__(self, *, contact_person: str, company_name: str, phone: str, email_list: List[str], **kwargs): + """ + :keyword contact_person: The contact person name. Required. + :paramtype contact_person: str + :keyword company_name: The name of the company. Required. + :paramtype company_name: str + :keyword phone: The phone number. Required. + :paramtype phone: str + :keyword email_list: The email list. Required. + :paramtype email_list: list[str] + """ + super().__init__(**kwargs) self.contact_person = contact_person self.company_name = company_name self.phone = phone @@ -563,13 +612,13 @@ class Container(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". + :ivar container_status: Current status of the container. Known values are: "OK", "Offline", + "Unknown", "Updating", and "NeedsAttention". :vartype container_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or + :ivar data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :vartype data_format: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AzureContainerDataFormat :ivar refresh_details: Details of the refresh job on this container. :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RefreshDetails @@ -578,39 +627,40 @@ class Container(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "container_status": {"readonly": True}, + "data_format": {"required": True}, + "refresh_details": {"readonly": True}, + "created_date_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - data_format: Union[str, "AzureContainerDataFormat"], - **kwargs - ): - super(Container, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "container_status": {"key": "properties.containerStatus", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, + } + + def __init__(self, *, data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs): + """ + :keyword data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.container_status = None self.data_format = data_format self.refresh_details = None self.created_date_time = None -class ContainerList(msrest.serialization.Model): +class ContainerList(_serialization.Model): """Collection of all the containers on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -622,25 +672,23 @@ class ContainerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Container]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevice(ARMBaseModel): +class DataBoxEdgeDevice(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -653,34 +701,33 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure + :ivar location: The location of the device. This is a supported and registered Azure geographical region (for example, West US, East US, or Southeast Asia). The geographical region of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or + specified on update, the request will succeed. Required. + :vartype location: str + :ivar tags: The list of tags that describe the device. These tags can be used to view and group + this device (across resource groups). + :vartype tags: dict[str, str] + :ivar sku: The SKU type. + :vartype sku: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Sku + :ivar etag: The etag for the devices. + :vartype etag: str + :ivar data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known values + are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :vartype data_box_edge_device_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDeviceStatus :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. :vartype serial_number: str - :param description: The Description of the Data Box Edge/Gateway device. - :type description: str - :param model_description: The description of the Data Box Edge/Gateway device model. - :type model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". + :ivar description: The Description of the Data Box Edge/Gateway device. + :vartype description: str + :ivar model_description: The description of the Data Box Edge/Gateway device model. + :vartype model_description: str + :ivar device_type: The type of the Data Box Edge/Gateway device. "DataBoxEdgeDevice" :vartype device_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DeviceType - :param friendly_name: The Data Box Edge/Gateway device name. - :type friendly_name: str + :ivar friendly_name: The Data Box Edge/Gateway device name. + :vartype friendly_name: str :ivar culture: The Data Box Edge/Gateway device culture. :vartype culture: str :ivar device_model: The Data Box Edge/Gateway device model. @@ -688,7 +735,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :ivar device_software_version: The Data Box Edge/Gateway device software version. :vartype device_software_version: str :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long + :vartype device_local_capacity: int :ivar time_zone: The Data Box Edge/Gateway device timezone. :vartype time_zone: str :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). @@ -701,44 +748,44 @@ class DataBoxEdgeDevice(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'serial_number': {'readonly': True}, - 'device_type': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "serial_number": {"readonly": True}, + "device_type": {"readonly": True}, + "culture": {"readonly": True}, + "device_model": {"readonly": True}, + "device_software_version": {"readonly": True}, + "device_local_capacity": {"readonly": True}, + "time_zone": {"readonly": True}, + "device_hcs_version": {"readonly": True}, + "configured_role_types": {"readonly": True}, + "node_count": {"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}"}, + "sku": {"key": "sku", "type": "Sku"}, + "etag": {"key": "etag", "type": "str"}, + "data_box_edge_device_status": {"key": "properties.dataBoxEdgeDeviceStatus", "type": "str"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "model_description": {"key": "properties.modelDescription", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "culture": {"key": "properties.culture", "type": "str"}, + "device_model": {"key": "properties.deviceModel", "type": "str"}, + "device_software_version": {"key": "properties.deviceSoftwareVersion", "type": "str"}, + "device_local_capacity": {"key": "properties.deviceLocalCapacity", "type": "int"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "device_hcs_version": {"key": "properties.deviceHcsVersion", "type": "str"}, + "configured_role_types": {"key": "properties.configuredRoleTypes", "type": "[str]"}, + "node_count": {"key": "properties.nodeCount", "type": "int"}, } def __init__( @@ -746,15 +793,40 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, etag: Optional[str] = None, - data_box_edge_device_status: Optional[Union[str, "DataBoxEdgeDeviceStatus"]] = None, + data_box_edge_device_status: Optional[Union[str, "_models.DataBoxEdgeDeviceStatus"]] = None, description: Optional[str] = None, model_description: Optional[str] = None, friendly_name: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) + """ + :keyword location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :paramtype location: str + :keyword tags: The list of tags that describe the device. These tags can be used to view and + group this device (across resource groups). + :paramtype tags: dict[str, str] + :keyword sku: The SKU type. + :paramtype sku: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Sku + :keyword etag: The etag for the devices. + :paramtype etag: str + :keyword data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known + values are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :paramtype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDeviceStatus + :keyword description: The Description of the Data Box Edge/Gateway device. + :paramtype description: str + :keyword model_description: The description of the Data Box Edge/Gateway device model. + :paramtype model_description: str + :keyword friendly_name: The Data Box Edge/Gateway device name. + :paramtype friendly_name: str + """ + super().__init__(**kwargs) self.location = location self.tags = tags self.sku = sku @@ -786,45 +858,48 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to + :ivar encryption_key_thumbprint: The digital signature of encrypted certificate. + :vartype encryption_key_thumbprint: str + :ivar encryption_key: The public part of the encryption certificate. Client uses this to encrypt any secret. - :type encryption_key: str + :vartype encryption_key: str :ivar resource_key: The Resource ID of the Resource. :vartype resource_key: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_key": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encryption_key_thumbprint": {"key": "properties.encryptionKeyThumbprint", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "str"}, + "resource_key": {"key": "properties.resourceKey", "type": "str"}, } def __init__( - self, - *, - encryption_key_thumbprint: Optional[str] = None, - encryption_key: Optional[str] = None, - **kwargs + self, *, encryption_key_thumbprint: Optional[str] = None, encryption_key: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) + """ + :keyword encryption_key_thumbprint: The digital signature of encrypted certificate. + :paramtype encryption_key_thumbprint: str + :keyword encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :paramtype encryption_key: str + """ + super().__init__(**kwargs) self.encryption_key_thumbprint = encryption_key_thumbprint self.encryption_key = encryption_key self.resource_key = None -class DataBoxEdgeDeviceList(msrest.serialization.Model): +class DataBoxEdgeDeviceList(_serialization.Model): """The collection of Data Box Edge/Gateway devices. Variables are only populated by the server, and will be ignored when sending a request. @@ -836,59 +911,56 @@ class DataBoxEdgeDeviceList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevicePatch(msrest.serialization.Model): +class DataBoxEdgeDevicePatch(_serialization.Model): """The Data Box Edge/Gateway device patch. - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] + :ivar tags: The tags attached to the Data Box Edge/Gateway resource. + :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: The tags attached to the Data Box Edge/Gateway resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) self.tags = tags -class DataBoxEdgeSku(msrest.serialization.Model): +class DataBoxEdgeSku(_serialization.Model): # pylint: disable=too-many-instance-attributes """The Sku information. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Large", "TCA_Small", "GPU". + :ivar name: The Sku name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Large", "TCA_Small", and "GPU". :vartype name: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuName :ivar kind: The Sku kind. :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". + :ivar tier: The Sku tier. "Standard" :vartype tier: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuTier :ivar size: The Sku kind. :vartype size: str @@ -905,55 +977,53 @@ class DataBoxEdgeSku(msrest.serialization.Model): :vartype costs: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuCost] :ivar restrictions: Restriction info of the SKU. :vartype restrictions: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuRestriction] - :ivar signup_option: Can the SKU be signed up.. Possible values include: "None", "Available". + :ivar signup_option: Can the SKU be signed up.. Known values are: "None" and "Available". :vartype signup_option: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuSignupOption - :ivar version: Sku version. Possible values include: "Stable", "Preview". + :ivar version: Sku version. Known values are: "Stable" and "Preview". :vartype version: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuVersion - :ivar availability: Is SKU available. Possible values include: "Available", "Unavailable". + :ivar availability: Is SKU available. Known values are: "Available" and "Unavailable". :vartype availability: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuAvailability """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'restrictions': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'restrictions': {'key': 'restrictions', 'type': '[SkuRestriction]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "kind": {"readonly": True}, + "tier": {"readonly": True}, + "size": {"readonly": True}, + "family": {"readonly": True}, + "locations": {"readonly": True}, + "api_versions": {"readonly": True}, + "location_info": {"readonly": True}, + "costs": {"readonly": True}, + "restrictions": {"readonly": True}, + "signup_option": {"readonly": True}, + "version": {"readonly": True}, + "availability": {"readonly": True}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "restrictions": {"key": "restrictions", "type": "[SkuRestriction]"}, + "signup_option": {"key": "signupOption", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "availability": {"key": "availability", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.kind = None @@ -970,7 +1040,7 @@ def __init__( self.availability = None -class DataBoxEdgeSkuList(msrest.serialization.Model): +class DataBoxEdgeSkuList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -982,20 +1052,18 @@ class DataBoxEdgeSkuList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -1003,8 +1071,8 @@ def __init__( class Trigger(ARMBaseModel): """Trigger details. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FileEventTrigger, PeriodicTimerEventTrigger Variables are only populated by the server, and will be ignored when sending a request. @@ -1016,35 +1084,30 @@ class Trigger(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerEventType + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerEventType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } + _subtype_map = {"kind": {"FileEvent": "FileEventTrigger", "PeriodicTimerEvent": "PeriodicTimerEventTrigger"}} - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.kind = 'Trigger' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None class FileEventTrigger(Trigger): @@ -1060,102 +1123,110 @@ class FileEventTrigger(Trigger): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerEventType + :ivar source_info: File event source details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.FileSourceInfo + :ivar sink_info: Role sink info. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "FileSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "FileSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.FileSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str + """ + :keyword source_info: File event source details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.FileSourceInfo + :keyword sink_info: Role sink info. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "FileEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class FileSourceInfo(msrest.serialization.Model): +class FileSourceInfo(_serialization.Model): """File source details. All required parameters must be populated in order to send to Azure. - :param share_id: Required. File share ID. - :type share_id: str + :ivar share_id: File share ID. Required. + :vartype share_id: str """ _validation = { - 'share_id': {'required': True}, + "share_id": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: File share ID. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id -class ImageRepositoryCredential(msrest.serialization.Model): +class ImageRepositoryCredential(_serialization.Model): """Image repository credential. All required parameters must be populated in order to send to Azure. - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret + :ivar image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :vartype image_repository_url: str + :ivar user_name: Repository user name. Required. + :vartype user_name: str + :ivar password: Repository user password. + :vartype password: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret """ _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, + "image_repository_url": {"required": True}, + "user_name": {"required": True}, } _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, + "image_repository_url": {"key": "imageRepositoryUrl", "type": "str"}, + "user_name": {"key": "userName", "type": "str"}, + "password": {"key": "password", "type": "AsymmetricEncryptedSecret"}, } def __init__( @@ -1163,40 +1234,49 @@ def __init__( *, image_repository_url: str, user_name: str, - password: Optional["AsymmetricEncryptedSecret"] = None, + password: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs ): - super(ImageRepositoryCredential, self).__init__(**kwargs) + """ + :keyword image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :paramtype image_repository_url: str + :keyword user_name: Repository user name. Required. + :paramtype user_name: str + :keyword password: Repository user password. + :paramtype password: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.image_repository_url = image_repository_url self.user_name = user_name self.password = password -class IoTDeviceInfo(msrest.serialization.Model): +class IoTDeviceInfo(_serialization.Model): """Metadata of IoT device/IoT Edge device to be configured. All required parameters must be populated in order to send to Azure. - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Authentication + :ivar device_id: ID of the IoT device/edge device. Required. + :vartype device_id: str + :ivar io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :vartype io_t_host_hub: str + :ivar io_t_host_hub_id: Id for the IoT hub associated to the device. + :vartype io_t_host_hub_id: str + :ivar authentication: Encrypted IoT device/IoT edge device connection string. + :vartype authentication: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Authentication """ _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, + "device_id": {"required": True}, + "io_t_host_hub": {"required": True}, } _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, + "device_id": {"key": "deviceId", "type": "str"}, + "io_t_host_hub": {"key": "ioTHostHub", "type": "str"}, + "io_t_host_hub_id": {"key": "ioTHostHubId", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, } def __init__( @@ -1205,39 +1285,49 @@ def __init__( device_id: str, io_t_host_hub: str, io_t_host_hub_id: Optional[str] = None, - authentication: Optional["Authentication"] = None, + authentication: Optional["_models.Authentication"] = None, **kwargs ): - super(IoTDeviceInfo, self).__init__(**kwargs) + """ + :keyword device_id: ID of the IoT device/edge device. Required. + :paramtype device_id: str + :keyword io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :paramtype io_t_host_hub: str + :keyword io_t_host_hub_id: Id for the IoT hub associated to the device. + :paramtype io_t_host_hub_id: str + :keyword authentication: Encrypted IoT device/IoT edge device connection string. + :paramtype authentication: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Authentication + """ + super().__init__(**kwargs) self.device_id = device_id self.io_t_host_hub = io_t_host_hub self.io_t_host_hub_id = io_t_host_hub_id self.authentication = authentication -class IoTEdgeAgentInfo(msrest.serialization.Model): +class IoTEdgeAgentInfo(_serialization.Model): """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. All required parameters must be populated in order to send to Azure. - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: + :ivar image_name: Name of the IoT edge agent image. Required. + :vartype image_name: str + :ivar tag: Image Tag. Required. + :vartype tag: str + :ivar image_repository: Image repository details. + :vartype image_repository: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ImageRepositoryCredential """ _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, + "image_name": {"required": True}, + "tag": {"required": True}, } _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, + "image_name": {"key": "imageName", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "image_repository": {"key": "imageRepository", "type": "ImageRepositoryCredential"}, } def __init__( @@ -1245,10 +1335,19 @@ def __init__( *, image_name: str, tag: str, - image_repository: Optional["ImageRepositoryCredential"] = None, + image_repository: Optional["_models.ImageRepositoryCredential"] = None, **kwargs ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) + """ + :keyword image_name: Name of the IoT edge agent image. Required. + :paramtype image_name: str + :keyword tag: Image Tag. Required. + :paramtype tag: str + :keyword image_repository: Image repository details. + :paramtype image_repository: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ImageRepositoryCredential + """ + super().__init__(**kwargs) self.image_name = image_name self.tag = tag self.image_repository = image_repository @@ -1257,8 +1356,8 @@ def __init__( class Role(ARMBaseModel): """Compute role. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: IoTRole. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + IoTRole Variables are only populated by the server, and will be ignored when sending a request. @@ -1270,38 +1369,33 @@ class Role(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", and "Cognitive". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleTypes """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'IOT': 'IoTRole'} - } + _subtype_map = {"kind": {"IOT": "IoTRole"}} - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None -class IoTRole(Role): +class IoTRole(Role): # pylint: disable=too-many-instance-attributes """Compute role. Variables are only populated by the server, and will be ignored when sending a request. @@ -1314,66 +1408,89 @@ class IoTRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleTypes - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", and "Cognitive". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleTypes + :ivar host_platform: Host OS supported by the IoT role. Known values are: "Windows" and "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.PlatformType + :ivar io_t_device_details: IoT device metadata to which data box edge device needs to be connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + :ivar share_mappings: Mount points of shares in role(s). + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MountPointMap] + :ivar io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :vartype io_t_edge_agent_info: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTEdgeAgentInfo + :ivar host_platform_type: Platform where the Iot runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.HostPlatformType - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'host_platform_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "host_platform_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "io_t_edge_agent_info": {"key": "properties.ioTEdgeAgentInfo", "type": "IoTEdgeAgentInfo"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - io_t_device_details: Optional["IoTDeviceInfo"] = None, - io_t_edge_device_details: Optional["IoTDeviceInfo"] = None, - share_mappings: Optional[List["MountPointMap"]] = None, - io_t_edge_agent_info: Optional["IoTEdgeAgentInfo"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + io_t_device_details: Optional["_models.IoTDeviceInfo"] = None, + io_t_edge_device_details: Optional["_models.IoTDeviceInfo"] = None, + share_mappings: Optional[List["_models.MountPointMap"]] = None, + io_t_edge_agent_info: Optional["_models.IoTEdgeAgentInfo"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str + """ + :keyword host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :paramtype host_platform: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.PlatformType + :keyword io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :paramtype io_t_device_details: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT role needs to be + configured. + :paramtype io_t_edge_device_details: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTDeviceInfo + :keyword share_mappings: Mount points of shares in role(s). + :paramtype share_mappings: + list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MountPointMap] + :keyword io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + runtime. + :paramtype io_t_edge_agent_info: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.IoTEdgeAgentInfo + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "IOT" self.host_platform = host_platform self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details @@ -1383,7 +1500,7 @@ def __init__( self.role_status = role_status -class Ipv4Config(msrest.serialization.Model): +class Ipv4Config(_serialization.Model): """Details related to the IPv4 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1397,28 +1514,26 @@ class Ipv4Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "subnet": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.subnet = None self.gateway = None -class Ipv6Config(msrest.serialization.Model): +class Ipv6Config(_serialization.Model): """Details related to the IPv6 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1432,28 +1547,26 @@ class Ipv6Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "prefix_length": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "int"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.prefix_length = None self.gateway = None -class Job(msrest.serialization.Model): +class Job(_serialization.Model): # pylint: disable=too-many-instance-attributes """A device job. Variables are only populated by the server, and will be ignored when sending a request. @@ -1464,8 +1577,8 @@ class Job(msrest.serialization.Model): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar status: The current status of the job. Known values are: "Invalid", "Running", + "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.JobStatus :ivar start_time: The UTC date and time at which the job started. :vartype start_time: ~datetime.datetime @@ -1475,13 +1588,13 @@ class Job(msrest.serialization.Model): :vartype percent_complete: int :ivar error: The error details. :vartype error: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer". + :ivar job_type: The type of the job. Known values are: "Invalid", "ScanForUpdates", + "DownloadUpdates", "InstallUpdates", "RefreshShare", and "RefreshContainer". :vartype job_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", + :ivar current_stage: Current stage of the update operation. Known values are: "Unknown", "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". + "Success", "Failure", "RescanStarted", "RescanComplete", and "RescanFailed". :vartype current_stage: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UpdateOperationStage :ivar download_progress: The download progress. @@ -1497,55 +1610,55 @@ class Job(msrest.serialization.Model): :vartype error_manifest_file: str :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, + :ivar folder: If only subfolders need to be refreshed, then the subfolder path inside the share + or container. (The path is empty if there are no subfolders.). + :vartype folder: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "error": {"readonly": True}, + "job_type": {"readonly": True}, + "current_stage": {"readonly": True}, + "download_progress": {"readonly": True}, + "install_progress": {"readonly": True}, + "total_refresh_errors": {"readonly": True}, + "error_manifest_file": {"readonly": True}, + "refreshed_entity_id": {"readonly": True}, } - def __init__( - self, - *, - folder: Optional[str] = None, - **kwargs - ): - super(Job, self).__init__(**kwargs) + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "error": {"key": "error", "type": "JobErrorDetails"}, + "job_type": {"key": "properties.jobType", "type": "str"}, + "current_stage": {"key": "properties.currentStage", "type": "str"}, + "download_progress": {"key": "properties.downloadProgress", "type": "UpdateDownloadProgress"}, + "install_progress": {"key": "properties.installProgress", "type": "UpdateInstallProgress"}, + "total_refresh_errors": {"key": "properties.totalRefreshErrors", "type": "int"}, + "error_manifest_file": {"key": "properties.errorManifestFile", "type": "str"}, + "refreshed_entity_id": {"key": "properties.refreshedEntityId", "type": "str"}, + "folder": {"key": "properties.folder", "type": "str"}, + } + + def __init__(self, *, folder: Optional[str] = None, **kwargs): + """ + :keyword folder: If only subfolders need to be refreshed, then the subfolder path inside the + share or container. (The path is empty if there are no subfolders.). + :paramtype folder: str + """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1564,7 +1677,7 @@ def __init__( self.folder = folder -class JobErrorDetails(msrest.serialization.Model): +class JobErrorDetails(_serialization.Model): """The job error information containing the list of job errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -1578,28 +1691,26 @@ class JobErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "error_details": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "error_details": {"key": "errorDetails", "type": "[JobErrorItem]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_details = None self.code = None self.message = None -class JobErrorItem(msrest.serialization.Model): +class JobErrorItem(_serialization.Model): """The job error items. Variables are only populated by the server, and will be ignored when sending a request. @@ -1613,42 +1724,40 @@ class JobErrorItem(msrest.serialization.Model): """ _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "recommendations": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "recommendations": {"key": "recommendations", "type": "[str]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.recommendations = None self.code = None self.message = None -class MetricDimensionV1(msrest.serialization.Model): +class MetricDimensionV1(_serialization.Model): """Metric Dimension v1. - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the metrics dimension. + :vartype name: str + :ivar display_name: Display name of the metrics dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -1659,56 +1768,64 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(MetricDimensionV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metrics dimension. + :paramtype name: str + :keyword display_name: Display name of the metrics dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecificationV1(msrest.serialization.Model): +class MetricSpecificationV1(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric specification version 1. - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Description of the metric to be displayed. + :vartype display_description: str + :ivar unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :vartype unit: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricUnit + :ivar aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :vartype aggregation_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or + :ivar dimensions: Metric dimensions, other than default dimension which is resource. + :vartype dimensions: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricDimensionV1] + :ivar fill_gap_with_zero: Set true to fill the gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar category: Metric category. Known values are: "Capacity" and "Transaction". + :vartype category: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricCategory + :ivar resource_id_dimension_name_override: Resource name override. + :vartype resource_id_dimension_name_override: str + :ivar supported_time_grain_types: Support granularity of metrics. + :vartype supported_time_grain_types: list[str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricAggregationType] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimensionV1]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, } def __init__( @@ -1717,17 +1834,47 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, display_description: Optional[str] = None, - unit: Optional[Union[str, "MetricUnit"]] = None, - aggregation_type: Optional[Union[str, "MetricAggregationType"]] = None, - dimensions: Optional[List["MetricDimensionV1"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, + dimensions: Optional[List["_models.MetricDimensionV1"]] = None, fill_gap_with_zero: Optional[bool] = None, - category: Optional[Union[str, "MetricCategory"]] = None, + category: Optional[Union[str, "_models.MetricCategory"]] = None, resource_id_dimension_name_override: Optional[str] = None, - supported_time_grain_types: Optional[List[Union[str, "TimeGrain"]]] = None, - supported_aggregation_types: Optional[List[Union[str, "MetricAggregationType"]]] = None, + supported_time_grain_types: Optional[List[Union[str, "_models.TimeGrain"]]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, **kwargs ): - super(MetricSpecificationV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Description of the metric to be displayed. + :paramtype display_description: str + :keyword unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :paramtype unit: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricUnit + :keyword aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :paramtype aggregation_type: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricAggregationType + :keyword dimensions: Metric dimensions, other than default dimension which is resource. + :paramtype dimensions: + list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricDimensionV1] + :keyword fill_gap_with_zero: Set true to fill the gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: Metric category. Known values are: "Capacity" and "Transaction". + :paramtype category: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricCategory + :keyword resource_id_dimension_name_override: Resource name override. + :paramtype resource_id_dimension_name_override: str + :keyword supported_time_grain_types: Support granularity of metrics. + :paramtype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TimeGrain] + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricAggregationType] + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1741,48 +1888,47 @@ def __init__( self.supported_aggregation_types = supported_aggregation_types -class MountPointMap(msrest.serialization.Model): +class MountPointMap(_serialization.Model): """The share mount point. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str + :ivar share_id: ID of the share mounted to the role VM. Required. + :vartype share_id: str :ivar role_id: ID of the role to which share is mounted. :vartype role_id: str :ivar mount_point: Mount point for the share. :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". + :ivar mount_type: Mounting type. Known values are: "Volume" and "HostPath". :vartype mount_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive". + :ivar role_type: Role type. Known values are: "IOT", "ASA", "Functions", and "Cognitive". :vartype role_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleTypes """ _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, + "share_id": {"required": True}, + "role_id": {"readonly": True}, + "mount_point": {"readonly": True}, + "mount_type": {"readonly": True}, + "role_type": {"readonly": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "mount_point": {"key": "mountPoint", "type": "str"}, + "mount_type": {"key": "mountType", "type": "str"}, + "role_type": {"key": "roleType", "type": "str"}, + } + + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: ID of the share mounted to the role VM. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id self.role_id = None self.mount_point = None @@ -1790,7 +1936,7 @@ def __init__( self.role_type = None -class NetworkAdapter(msrest.serialization.Model): +class NetworkAdapter(_serialization.Model): # pylint: disable=too-many-instance-attributes """Represents the networkAdapter on a device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1811,17 +1957,17 @@ class NetworkAdapter(msrest.serialization.Model): :ivar mac_address: MAC address. :vartype mac_address: str :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". + :vartype link_speed: int + :ivar status: Value indicating whether this adapter is valid. Known values are: "Inactive" and + "Active". :vartype status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or + :ivar rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :vartype rdma_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or + :ivar dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :vartype dhcp_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapterDHCPStatus :ivar ipv4_configuration: The IPv4 configuration of the network adapter. :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Ipv4Config @@ -1834,47 +1980,57 @@ class NetworkAdapter(msrest.serialization.Model): """ _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, + "adapter_id": {"readonly": True}, + "adapter_position": {"readonly": True}, + "index": {"readonly": True}, + "node_id": {"readonly": True}, + "network_adapter_name": {"readonly": True}, + "label": {"readonly": True}, + "mac_address": {"readonly": True}, + "link_speed": {"readonly": True}, + "status": {"readonly": True}, + "ipv4_configuration": {"readonly": True}, + "ipv6_configuration": {"readonly": True}, + "ipv6_link_local_address": {"readonly": True}, + "dns_servers": {"readonly": True}, + } + + _attribute_map = { + "adapter_id": {"key": "adapterId", "type": "str"}, + "adapter_position": {"key": "adapterPosition", "type": "NetworkAdapterPosition"}, + "index": {"key": "index", "type": "int"}, + "node_id": {"key": "nodeId", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "mac_address": {"key": "macAddress", "type": "str"}, + "link_speed": {"key": "linkSpeed", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "rdma_status": {"key": "rdmaStatus", "type": "str"}, + "dhcp_status": {"key": "dhcpStatus", "type": "str"}, + "ipv4_configuration": {"key": "ipv4Configuration", "type": "Ipv4Config"}, + "ipv6_configuration": {"key": "ipv6Configuration", "type": "Ipv6Config"}, + "ipv6_link_local_address": {"key": "ipv6LinkLocalAddress", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, } def __init__( self, *, - rdma_status: Optional[Union[str, "NetworkAdapterRDMAStatus"]] = None, - dhcp_status: Optional[Union[str, "NetworkAdapterDHCPStatus"]] = None, + rdma_status: Optional[Union[str, "_models.NetworkAdapterRDMAStatus"]] = None, + dhcp_status: Optional[Union[str, "_models.NetworkAdapterDHCPStatus"]] = None, **kwargs ): - super(NetworkAdapter, self).__init__(**kwargs) + """ + :keyword rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :paramtype rdma_status: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapterRDMAStatus + :keyword dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :paramtype dhcp_status: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkAdapterDHCPStatus + """ + super().__init__(**kwargs) self.adapter_id = None self.adapter_position = None self.index = None @@ -1892,32 +2048,30 @@ def __init__( self.dns_servers = None -class NetworkAdapterPosition(msrest.serialization.Model): +class NetworkAdapterPosition(_serialization.Model): """The network adapter position. Variables are only populated by the server, and will be ignored when sending a request. - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". + :ivar network_group: The network group. Known values are: "None", "NonRDMA", and "RDMA". :vartype network_group: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkGroup :ivar port: The port. :vartype port: int """ _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, + "network_group": {"readonly": True}, + "port": {"readonly": True}, } _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, + "network_group": {"key": "networkGroup", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_group = None self.port = None @@ -1939,89 +2093,85 @@ class NetworkSettings(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "network_adapters": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "network_adapters": {"key": "properties.networkAdapters", "type": "[NetworkAdapter]"}, } - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_adapters = None class Node(ARMBaseModel): """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. + Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node + Multi-node Edge devices will have more than 1 nodes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar node_status: The current status of the individual node. Known values are: "Unknown", + "Up", "Down", "Rebooting", and "ShuttingDown". + :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NodeStatus + :ivar node_chassis_serial_number: Serial number of the Chassis. + :vartype node_chassis_serial_number: str + :ivar node_serial_number: Serial number of the individual node. + :vartype node_serial_number: str + :ivar node_display_name: Display Name of the individual node. + :vartype node_display_name: str + :ivar node_friendly_software_version: Friendly software version name that is currently + installed on the node. + :vartype node_friendly_software_version: str + :ivar node_hcs_version: HCS version that is currently installed on the node. + :vartype node_hcs_version: str + :ivar node_instance_id: Guid instance id of the node. + :vartype node_instance_id: str + """ - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "node_status": {"readonly": True}, + "node_chassis_serial_number": {"readonly": True}, + "node_serial_number": {"readonly": True}, + "node_display_name": {"readonly": True}, + "node_friendly_software_version": {"readonly": True}, + "node_hcs_version": {"readonly": True}, + "node_instance_id": {"readonly": True}, } - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "node_status": {"key": "properties.nodeStatus", "type": "str"}, + "node_chassis_serial_number": {"key": "properties.nodeChassisSerialNumber", "type": "str"}, + "node_serial_number": {"key": "properties.nodeSerialNumber", "type": "str"}, + "node_display_name": {"key": "properties.nodeDisplayName", "type": "str"}, + "node_friendly_software_version": {"key": "properties.nodeFriendlySoftwareVersion", "type": "str"}, + "node_hcs_version": {"key": "properties.nodeHcsVersion", "type": "str"}, + "node_instance_id": {"key": "properties.nodeInstanceId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.node_status = None self.node_chassis_serial_number = None self.node_serial_number = None @@ -2031,7 +2181,7 @@ def __init__( self.node_instance_id = None -class NodeList(msrest.serialization.Model): +class NodeList(_serialization.Model): """Collection of Nodes. Variables are only populated by the server, and will be ignored when sending a request. @@ -2041,76 +2191,85 @@ class NodeList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, + "value": {"key": "value", "type": "[Node]"}, } - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operations. - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param service_specification: Service specification. - :type service_specification: + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties displayed for the operation. + :vartype display: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar service_specification: Service specification. + :vartype service_specification: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ServiceSpecification """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): - super(Operation, self).__init__(**kwargs) + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties displayed for the operation. + :paramtype display: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword service_specification: Service specification. + :paramtype service_specification: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ServiceSpecification + """ + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display properties. - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: The type of resource in which the operation is performed. + :vartype resource: str + :ivar operation: Operation to be performed on the resource. + :vartype operation: str + :ivar description: Description of the operation to be performed. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2122,41 +2281,51 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: The type of resource in which the operation is performed. + :paramtype resource: str + :keyword operation: Operation to be performed on the resource. + :paramtype operation: str + :keyword description: Description of the operation to be performed. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsList(msrest.serialization.Model): +class OperationsList(_serialization.Model): """The list of operations used for the discovery of available provider operations. All required parameters must be populated in order to send to Azure. - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar value: The value. Required. + :vartype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Operation] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: List["Operation"], - next_link: Optional[str] = None, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The value. Required. + :paramtype value: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Operation] + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -2172,12 +2341,12 @@ class Order(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Address - :param current_status: Current status of the order. - :type current_status: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderStatus + :ivar contact_information: The contact details. + :vartype contact_information: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ContactDetails + :ivar shipping_address: The shipping address. + :vartype shipping_address: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Address + :ivar current_status: Current status of the order. + :vartype current_status: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderStatus :ivar order_history: List of status changes in the order. :vartype order_history: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderStatus] :ivar serial_number: Serial number of the device. @@ -2193,37 +2362,46 @@ class Order(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "order_history": {"readonly": True}, + "serial_number": {"readonly": True}, + "delivery_tracking_info": {"readonly": True}, + "return_tracking_info": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "contact_information": {"key": "properties.contactInformation", "type": "ContactDetails"}, + "shipping_address": {"key": "properties.shippingAddress", "type": "Address"}, + "current_status": {"key": "properties.currentStatus", "type": "OrderStatus"}, + "order_history": {"key": "properties.orderHistory", "type": "[OrderStatus]"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "delivery_tracking_info": {"key": "properties.deliveryTrackingInfo", "type": "[TrackingInfo]"}, + "return_tracking_info": {"key": "properties.returnTrackingInfo", "type": "[TrackingInfo]"}, } def __init__( self, *, - contact_information: Optional["ContactDetails"] = None, - shipping_address: Optional["Address"] = None, - current_status: Optional["OrderStatus"] = None, + contact_information: Optional["_models.ContactDetails"] = None, + shipping_address: Optional["_models.Address"] = None, + current_status: Optional["_models.OrderStatus"] = None, **kwargs ): - super(Order, self).__init__(**kwargs) + """ + :keyword contact_information: The contact details. + :paramtype contact_information: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ContactDetails + :keyword shipping_address: The shipping address. + :paramtype shipping_address: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Address + :keyword current_status: Current status of the order. + :paramtype current_status: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderStatus + """ + super().__init__(**kwargs) self.contact_information = contact_information self.shipping_address = shipping_address self.current_status = current_status @@ -2233,7 +2411,7 @@ def __init__( self.return_tracking_info = None -class OrderList(msrest.serialization.Model): +class OrderList(_serialization.Model): """List of order entities. Variables are only populated by the server, and will be ignored when sending a request. @@ -2245,66 +2423,67 @@ class OrderList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Order]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OrderStatus(msrest.serialization.Model): +class OrderStatus(_serialization.Model): """Represents a single status change. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft". - :type status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderState + :ivar status: Status of the order as per the allowed status types. Required. Known values are: + "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", and "CollectedAtMicrosoft". + :vartype status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderState :ivar update_date_time: Time of status update. :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str + :ivar comments: Comments related to this status change. + :vartype comments: str :ivar additional_order_details: Dictionary to hold generic information which is not stored by the already existing properties. :vartype additional_order_details: dict[str, str] """ _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'additional_order_details': {'readonly': True}, + "status": {"required": True}, + "update_date_time": {"readonly": True}, + "additional_order_details": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - *, - status: Union[str, "OrderState"], - comments: Optional[str] = None, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) + "status": {"key": "status", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + "comments": {"key": "comments", "type": "str"}, + "additional_order_details": {"key": "additionalOrderDetails", "type": "{str}"}, + } + + def __init__(self, *, status: Union[str, "_models.OrderState"], comments: Optional[str] = None, **kwargs): + """ + :keyword status: Status of the order as per the allowed status types. Required. Known values + are: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", and "CollectedAtMicrosoft". + :paramtype status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderState + :keyword comments: Comments related to this status change. + :paramtype comments: str + """ + super().__init__(**kwargs) self.status = status self.update_date_time = None self.comments = comments @@ -2324,119 +2503,134 @@ class PeriodicTimerEventTrigger(Trigger): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerEventType + :ivar source_info: Periodic timer details. Required. + :vartype source_info: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.PeriodicTimerSourceInfo + :ivar sink_info: Role Sink information. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "PeriodicTimerSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "PeriodicTimerSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.PeriodicTimerSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str + """ + :keyword source_info: Periodic timer details. Required. + :paramtype source_info: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.PeriodicTimerSourceInfo + :keyword sink_info: Role Sink information. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "PeriodicTimerEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class PeriodicTimerSourceInfo(msrest.serialization.Model): +class PeriodicTimerSourceInfo(_serialization.Model): """Periodic timer event source. All required parameters must be populated in order to send to Azure. - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str + :ivar start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :vartype start_time: ~datetime.datetime + :ivar schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :vartype schedule: str + :ivar topic: Topic where periodic events are published to IoT device. + :vartype topic: str """ _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, + "start_time": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - *, - start_time: datetime.datetime, - schedule: str, - topic: Optional[str] = None, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) + "start_time": {"key": "startTime", "type": "iso-8601"}, + "schedule": {"key": "schedule", "type": "str"}, + "topic": {"key": "topic", "type": "str"}, + } + + def __init__(self, *, start_time: datetime.datetime, schedule: str, topic: Optional[str] = None, **kwargs): + """ + :keyword start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :paramtype start_time: ~datetime.datetime + :keyword schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :paramtype schedule: str + :keyword topic: Topic where periodic events are published to IoT device. + :paramtype topic: str + """ + super().__init__(**kwargs) self.start_time = start_time self.schedule = schedule self.topic = topic -class RefreshDetails(msrest.serialization.Model): +class RefreshDetails(_serialization.Model): """Fields for tracking refresh job on the share or container. - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + :ivar in_progress_refresh_job_id: If a refresh job is currently in progress on this share or container, this field indicates the ARM resource ID of that job. The field is empty if no job is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh + :vartype in_progress_refresh_job_id: str + :ivar last_completed_refresh_job_time_in_utc: Indicates the completed time for the last refresh + job on this particular share or container, if any.This could be a failed job or a successful + job. + :vartype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :ivar error_manifest_file: Indicates the relative path of the error xml for the last refresh job on this particular share or container, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or + :vartype error_manifest_file: str + :ivar last_job: Indicates the id of the last refresh job on this particular share or container,if any. This could be a failed job or a successful job. - :type last_job: str + :vartype last_job: str """ _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, + "in_progress_refresh_job_id": {"key": "inProgressRefreshJobId", "type": "str"}, + "last_completed_refresh_job_time_in_utc": {"key": "lastCompletedRefreshJobTimeInUTC", "type": "iso-8601"}, + "error_manifest_file": {"key": "errorManifestFile", "type": "str"}, + "last_job": {"key": "lastJob", "type": "str"}, } def __init__( @@ -2448,27 +2642,44 @@ def __init__( last_job: Optional[str] = None, **kwargs ): - super(RefreshDetails, self).__init__(**kwargs) + """ + :keyword in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + container, this field indicates the ARM resource ID of that job. The field is empty if no job + is in progress. + :paramtype in_progress_refresh_job_id: str + :keyword last_completed_refresh_job_time_in_utc: Indicates the completed time for the last + refresh job on this particular share or container, if any.This could be a failed job or a + successful job. + :paramtype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :keyword error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share or container, if any. This could be a failed job or a successful + job. + :paramtype error_manifest_file: str + :keyword last_job: Indicates the id of the last refresh job on this particular share or + container,if any. This could be a failed job or a successful job. + :paramtype last_job: str + """ + super().__init__(**kwargs) self.in_progress_refresh_job_id = in_progress_refresh_job_id self.last_completed_refresh_job_time_in_utc = last_completed_refresh_job_time_in_utc self.error_manifest_file = error_manifest_file self.last_job = last_job -class ResourceTypeSku(msrest.serialization.Model): +class ResourceTypeSku(_serialization.Model): """SkuInformation object. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Large", "TCA_Small", "GPU". + :ivar name: The Sku name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Large", "TCA_Small", and "GPU". :vartype name: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuName :ivar kind: The Sku kind. :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". + :ivar tier: The Sku tier. "Standard" :vartype tier: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuTier :ivar family: The Sku family. :vartype family: str @@ -2486,36 +2697,34 @@ class ResourceTypeSku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'restrictions': {'readonly': True}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "kind": {"readonly": True}, + "tier": {"readonly": True}, + "family": {"readonly": True}, + "locations": {"readonly": True}, + "api_versions": {"readonly": True}, + "location_info": {"readonly": True}, + "costs": {"readonly": True}, + "restrictions": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'restrictions': {'key': 'restrictions', 'type': '[SkuRestriction]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "restrictions": {"key": "restrictions", "type": "[SkuRestriction]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.kind = None @@ -2528,7 +2737,7 @@ def __init__( self.restrictions = None -class RoleList(msrest.serialization.Model): +class RoleList(_serialization.Model): """Collection of all the roles on the Data Box Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2540,48 +2749,45 @@ class RoleList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Role]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RoleSinkInfo(msrest.serialization.Model): +class RoleSinkInfo(_serialization.Model): """Compute role against which events will be raised. All required parameters must be populated in order to send to Azure. - :param role_id: Required. Compute role ID. - :type role_id: str + :ivar role_id: Compute role ID. Required. + :vartype role_id: str """ _validation = { - 'role_id': {'required': True}, + "role_id": {"required": True}, } _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, + "role_id": {"key": "roleId", "type": "str"}, } - def __init__( - self, - *, - role_id: str, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) + def __init__(self, *, role_id: str, **kwargs): + """ + :keyword role_id: Compute role ID. Required. + :paramtype role_id: str + """ + super().__init__(**kwargs) self.role_id = role_id @@ -2598,61 +2804,64 @@ class SecuritySettings(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: + :ivar device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :vartype device_admin_password: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "device_admin_password": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - *, - device_admin_password: "AsymmetricEncryptedSecret", - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_admin_password": {"key": "properties.deviceAdminPassword", "type": "AsymmetricEncryptedSecret"}, + } + + def __init__(self, *, device_admin_password: "_models.AsymmetricEncryptedSecret", **kwargs): + """ + :keyword device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :paramtype device_admin_password: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.device_admin_password = device_admin_password -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification. - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: + :ivar metric_specifications: Metric specification as defined by shoebox. + :vartype metric_specifications: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricSpecificationV1] """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecificationV1]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["MetricSpecificationV1"]] = None, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecificationV1"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specification as defined by shoebox. + :paramtype metric_specifications: + list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MetricSpecificationV1] + """ + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Share(ARMBaseModel): +class Share(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Represents a share on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2665,79 +2874,109 @@ class Share(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or + :ivar description: Description for the share. + :vartype description: str + :ivar share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :vartype share_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareStatus + :ivar monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :vartype monitoring_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: + :ivar azure_container_info: Azure container mapping for the share. + :vartype azure_container_info: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or + :ivar access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :vartype access_protocol: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share + :ivar user_access_rights: Mapping of users and corresponding access rights on the share (required for SMB protocol). - :type user_access_rights: + :vartype user_access_rights: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the + :ivar client_access_rights: List of IP addresses and corresponding access rights on the share(required for NFS protocol). - :type client_access_rights: + :vartype client_access_rights: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RefreshDetails + :ivar refresh_details: Details of the refresh job on this share. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RefreshDetails :ivar share_mappings: Share mount point to the role. :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataPolicy + :ivar data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "share_status": {"required": True}, + "monitoring_status": {"required": True}, + "access_protocol": {"required": True}, + "share_mappings": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "share_status": {"key": "properties.shareStatus", "type": "str"}, + "monitoring_status": {"key": "properties.monitoringStatus", "type": "str"}, + "azure_container_info": {"key": "properties.azureContainerInfo", "type": "AzureContainerInfo"}, + "access_protocol": {"key": "properties.accessProtocol", "type": "str"}, + "user_access_rights": {"key": "properties.userAccessRights", "type": "[UserAccessRight]"}, + "client_access_rights": {"key": "properties.clientAccessRights", "type": "[ClientAccessRight]"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, } def __init__( self, *, - share_status: Union[str, "ShareStatus"], - monitoring_status: Union[str, "MonitoringStatus"], - access_protocol: Union[str, "ShareAccessProtocol"], + share_status: Union[str, "_models.ShareStatus"], + monitoring_status: Union[str, "_models.MonitoringStatus"], + access_protocol: Union[str, "_models.ShareAccessProtocol"], description: Optional[str] = None, - azure_container_info: Optional["AzureContainerInfo"] = None, - user_access_rights: Optional[List["UserAccessRight"]] = None, - client_access_rights: Optional[List["ClientAccessRight"]] = None, - refresh_details: Optional["RefreshDetails"] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, + azure_container_info: Optional["_models.AzureContainerInfo"] = None, + user_access_rights: Optional[List["_models.UserAccessRight"]] = None, + client_access_rights: Optional[List["_models.ClientAccessRight"]] = None, + refresh_details: Optional["_models.RefreshDetails"] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, **kwargs ): - super(Share, self).__init__(**kwargs) + """ + :keyword description: Description for the share. + :paramtype description: str + :keyword share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :paramtype share_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareStatus + :keyword monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :paramtype monitoring_status: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.MonitoringStatus + :keyword azure_container_info: Azure container mapping for the share. + :paramtype azure_container_info: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AzureContainerInfo + :keyword access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :paramtype access_protocol: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessProtocol + :keyword user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :paramtype user_access_rights: + list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.UserAccessRight] + :keyword client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :paramtype client_access_rights: + list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ClientAccessRight] + :keyword refresh_details: Details of the refresh job on this share. + :paramtype refresh_details: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.RefreshDetails + :keyword data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataPolicy + """ + super().__init__(**kwargs) self.description = description self.share_status = share_status self.monitoring_status = monitoring_status @@ -2750,41 +2989,43 @@ def __init__( self.data_policy = data_policy -class ShareAccessRight(msrest.serialization.Model): +class ShareAccessRight(_serialization.Model): """Specifies the mapping between this particular user and the type of access he has on shares on this device. All required parameters must be populated in order to send to Azure. - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessType + :ivar share_id: The share ID. Required. + :vartype share_id: str + :ivar access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessType """ _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, + "share_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, share_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword share_id: The share ID. Required. + :paramtype share_id: str + :keyword access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :paramtype access_type: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessType + """ + super().__init__(**kwargs) self.share_id = share_id self.access_type = access_type -class ShareList(msrest.serialization.Model): +class ShareList(_serialization.Model): """Collection of all the shares on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -2796,53 +3037,59 @@ class ShareList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Share]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU type. - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Large", "TCA_Small", "GPU". - :type name: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuTier + :ivar name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Large", "TCA_Small", and "GPU". + :vartype name: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuTier """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "SkuName"]] = None, - tier: Optional[Union[str, "SkuTier"]] = None, + name: Optional[Union[str, "_models.SkuName"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, **kwargs ): - super(Sku, self).__init__(**kwargs) + """ + :keyword name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Large", "TCA_Small", and "GPU". + :paramtype name: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuName + :keyword tier: The SKU tier. This is based on the SKU name. "Standard" + :paramtype tier: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuTier + """ + super().__init__(**kwargs) self.name = name self.tier = tier -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capabilities of the SKU. Variables are only populated by the server, and will be ignored when sending a request. @@ -2854,25 +3101,23 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuCost(msrest.serialization.Model): +class SkuCost(_serialization.Model): """The metadata for retrieving price info. Variables are only populated by the server, and will be ignored when sending a request. @@ -2880,34 +3125,32 @@ class SkuCost(msrest.serialization.Model): :ivar meter_id: Used for querying price from commerce. :vartype meter_id: str :ivar quantity: The cost quantity. - :vartype quantity: long + :vartype quantity: int :ivar extended_unit: The extended unit. :vartype extended_unit: str """ _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, + "meter_id": {"readonly": True}, + "quantity": {"readonly": True}, + "extended_unit": {"readonly": True}, } _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, + "meter_id": {"key": "meterId", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.meter_id = None self.quantity = None self.extended_unit = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): # pylint: disable=too-many-instance-attributes """Sku information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2940,40 +3183,38 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, - 'costs': {'readonly': True}, - 'capabilities': {'readonly': True}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "tier": {"readonly": True}, + "kind": {"readonly": True}, + "size": {"readonly": True}, + "family": {"readonly": True}, + "locations": {"readonly": True}, + "location_info": {"readonly": True}, + "required_quota_ids": {"readonly": True}, + "required_features": {"readonly": True}, + "costs": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "required_quota_ids": {"key": "requiredQuotaIds", "type": "[str]"}, + "required_features": {"key": "requiredFeatures", "type": "[str]"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.tier = None @@ -2988,7 +3229,7 @@ def __init__( self.capabilities = None -class SkuInformationList(msrest.serialization.Model): +class SkuInformationList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -3000,25 +3241,23 @@ class SkuInformationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceTypeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SkuLocationInfo(msrest.serialization.Model): +class SkuLocationInfo(_serialization.Model): """The location info. Variables are only populated by the server, and will be ignored when sending a request. @@ -3032,28 +3271,26 @@ class SkuLocationInfo(msrest.serialization.Model): """ _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, + "location": {"readonly": True}, + "zones": {"readonly": True}, + "sites": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "sites": {"key": "sites", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.zones = None self.sites = None -class SkuRestriction(msrest.serialization.Model): +class SkuRestriction(_serialization.Model): """The restrictions because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -3062,8 +3299,8 @@ class SkuRestriction(msrest.serialization.Model): :vartype type: str :ivar values: The locations where sku is restricted. :vartype values: list[str] - :ivar reason_code: The SKU restriction reason. Possible values include: - "NotAvailableForSubscription", "QuotaId". + :ivar reason_code: The SKU restriction reason. Known values are: "NotAvailableForSubscription" + and "QuotaId". :vartype reason_code: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuRestrictionReasonCode :ivar restriction_info: Restriction of the SKU for the location/zone. @@ -3072,31 +3309,29 @@ class SkuRestriction(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, - 'reason_code': {'readonly': True}, - 'restriction_info': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, + "reason_code": {"readonly": True}, + "restriction_info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, - 'restriction_info': {'key': 'restrictionInfo', 'type': 'SkuRestrictionInfo'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, + "restriction_info": {"key": "restrictionInfo", "type": "SkuRestrictionInfo"}, } - def __init__( - self, - **kwargs - ): - super(SkuRestriction, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = None self.restriction_info = None -class SkuRestrictionInfo(msrest.serialization.Model): +class SkuRestrictionInfo(_serialization.Model): """The restriction info with locations and zones. Variables are only populated by the server, and will be ignored when sending a request. @@ -3108,20 +3343,18 @@ class SkuRestrictionInfo(msrest.serialization.Model): """ _validation = { - 'locations': {'readonly': True}, - 'zones': {'readonly': True}, + "locations": {"readonly": True}, + "zones": {"readonly": True}, } _attribute_map = { - 'locations': {'key': 'locations', 'type': '[str]'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "locations": {"key": "locations", "type": "[str]"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - super(SkuRestrictionInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.locations = None self.zones = None @@ -3137,17 +3370,16 @@ class StorageAccount(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or + :ivar description: Description for the storage Account. + :vartype description: str + :ivar storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :vartype storage_account_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountStatus - :param data_policy: Data policy of the storage Account. Possible values include: "Cloud", - "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str + :ivar data_policy: Data policy of the storage Account. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataPolicy + :ivar storage_account_credential_id: Storage Account Credential Id. + :vartype storage_account_credential_id: str :ivar blob_endpoint: BlobEndpoint of Storage Account. :vartype blob_endpoint: str :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy @@ -3156,35 +3388,48 @@ class StorageAccount(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "blob_endpoint": {"readonly": True}, + "container_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "storage_account_status": {"key": "properties.storageAccountStatus", "type": "str"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, + "storage_account_credential_id": {"key": "properties.storageAccountCredentialId", "type": "str"}, + "blob_endpoint": {"key": "properties.blobEndpoint", "type": "str"}, + "container_count": {"key": "properties.containerCount", "type": "int"}, } def __init__( self, *, description: Optional[str] = None, - storage_account_status: Optional[Union[str, "StorageAccountStatus"]] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, + storage_account_status: Optional[Union[str, "_models.StorageAccountStatus"]] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, storage_account_credential_id: Optional[str] = None, **kwargs ): - super(StorageAccount, self).__init__(**kwargs) + """ + :keyword description: Description for the storage Account. + :paramtype description: str + :keyword storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :paramtype storage_account_status: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountStatus + :keyword data_policy: Data policy of the storage Account. Known values are: "Cloud" and + "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataPolicy + :keyword storage_account_credential_id: Storage Account Credential Id. + :paramtype storage_account_credential_id: str + """ + super().__init__(**kwargs) self.description = description self.storage_account_status = storage_account_status self.data_policy = data_policy @@ -3193,7 +3438,7 @@ def __init__( self.container_count = None -class StorageAccountCredential(ARMBaseModel): +class StorageAccountCredential(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The storage account credential. Variables are only populated by the server, and will be ignored when sending a request. @@ -3206,64 +3451,87 @@ class StorageAccountCredential(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + :ivar alias: Alias for the storage account. Required. + :vartype alias: str + :ivar user_name: Username for the storage account. + :vartype user_name: str + :ivar account_key: Encrypted storage key. + :vartype account_key: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string for the storage account. Use this string if username + and account key are not specified. + :vartype connection_string: str + :ivar ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values are: + "Enabled" and "Disabled". + :vartype ssl_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SSLStatus + :ivar blob_domain_name: Blob end point for private clouds. + :vartype blob_domain_name: str + :ivar account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :vartype account_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AccountType + :ivar storage_account_id: Id of the storage account. + :vartype storage_account_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "alias": {"required": True}, + "ssl_status": {"required": True}, + "account_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "alias": {"key": "properties.alias", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "account_key": {"key": "properties.accountKey", "type": "AsymmetricEncryptedSecret"}, + "connection_string": {"key": "properties.connectionString", "type": "str"}, + "ssl_status": {"key": "properties.sslStatus", "type": "str"}, + "blob_domain_name": {"key": "properties.blobDomainName", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, } def __init__( self, *, alias: str, - ssl_status: Union[str, "SSLStatus"], - account_type: Union[str, "AccountType"], + ssl_status: Union[str, "_models.SSLStatus"], + account_type: Union[str, "_models.AccountType"], user_name: Optional[str] = None, - account_key: Optional["AsymmetricEncryptedSecret"] = None, + account_key: Optional["_models.AsymmetricEncryptedSecret"] = None, connection_string: Optional[str] = None, blob_domain_name: Optional[str] = None, storage_account_id: Optional[str] = None, **kwargs ): - super(StorageAccountCredential, self).__init__(**kwargs) + """ + :keyword alias: Alias for the storage account. Required. + :paramtype alias: str + :keyword user_name: Username for the storage account. + :paramtype user_name: str + :keyword account_key: Encrypted storage key. + :paramtype account_key: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret + :keyword connection_string: Connection string for the storage account. Use this string if + username and account key are not specified. + :paramtype connection_string: str + :keyword ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values + are: "Enabled" and "Disabled". + :paramtype ssl_status: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SSLStatus + :keyword blob_domain_name: Blob end point for private clouds. + :paramtype blob_domain_name: str + :keyword account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :paramtype account_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AccountType + :keyword storage_account_id: Id of the storage account. + :paramtype storage_account_id: str + """ + super().__init__(**kwargs) self.alias = alias self.user_name = user_name self.account_key = account_key @@ -3274,7 +3542,7 @@ def __init__( self.storage_account_id = storage_account_id -class StorageAccountCredentialList(msrest.serialization.Model): +class StorageAccountCredentialList(_serialization.Model): """The collection of storage account credentials. Variables are only populated by the server, and will be ignored when sending a request. @@ -3287,25 +3555,23 @@ class StorageAccountCredentialList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccountCredential]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountList(msrest.serialization.Model): +class StorageAccountList(_serialization.Model): """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -3317,64 +3583,62 @@ class StorageAccountList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SymmetricKey(msrest.serialization.Model): +class SymmetricKey(_serialization.Model): """Symmetric key for authentication. - :param connection_string: Connection string based on the symmetric key. - :type connection_string: + :ivar connection_string: Connection string based on the symmetric key. + :vartype connection_string: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret """ _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, + "connection_string": {"key": "connectionString", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) + def __init__(self, *, connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs): + """ + :keyword connection_string: Connection string based on the symmetric key. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.connection_string = connection_string -class TrackingInfo(msrest.serialization.Model): +class TrackingInfo(_serialization.Model): """Tracking courier information. - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str + :ivar serial_number: Serial number of the device being tracked. + :vartype serial_number: str + :ivar carrier_name: Name of the carrier used in the delivery. + :vartype carrier_name: str + :ivar tracking_id: Tracking ID of the shipment. + :vartype tracking_id: str + :ivar tracking_url: Tracking URL of the shipment. + :vartype tracking_url: str """ _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, + "serial_number": {"key": "serialNumber", "type": "str"}, + "carrier_name": {"key": "carrierName", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "tracking_url": {"key": "trackingUrl", "type": "str"}, } def __init__( @@ -3386,14 +3650,24 @@ def __init__( tracking_url: Optional[str] = None, **kwargs ): - super(TrackingInfo, self).__init__(**kwargs) + """ + :keyword serial_number: Serial number of the device being tracked. + :paramtype serial_number: str + :keyword carrier_name: Name of the carrier used in the delivery. + :paramtype carrier_name: str + :keyword tracking_id: Tracking ID of the shipment. + :paramtype tracking_id: str + :keyword tracking_url: Tracking URL of the shipment. + :paramtype tracking_url: str + """ + super().__init__(**kwargs) self.serial_number = serial_number self.carrier_name = carrier_name self.tracking_id = tracking_id self.tracking_url = tracking_url -class TriggerList(msrest.serialization.Model): +class TriggerList(_serialization.Model): """Collection of all trigger on the data box edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -3405,31 +3679,29 @@ class TriggerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Trigger]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class UpdateDownloadProgress(msrest.serialization.Model): +class UpdateDownloadProgress(_serialization.Model): """Details about the download progress of update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". + :ivar download_phase: The download phase. Known values are: "Unknown", "Initializing", + "Downloading", and "Verifying". :vartype download_phase: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DownloadPhase :ivar percent_complete: Percentage of completion. @@ -3445,28 +3717,26 @@ class UpdateDownloadProgress(msrest.serialization.Model): """ _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, + "download_phase": {"readonly": True}, + "percent_complete": {"readonly": True}, + "total_bytes_to_download": {"readonly": True}, + "total_bytes_downloaded": {"readonly": True}, + "number_of_updates_to_download": {"readonly": True}, + "number_of_updates_downloaded": {"readonly": True}, } _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, + "download_phase": {"key": "downloadPhase", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "total_bytes_to_download": {"key": "totalBytesToDownload", "type": "float"}, + "total_bytes_downloaded": {"key": "totalBytesDownloaded", "type": "float"}, + "number_of_updates_to_download": {"key": "numberOfUpdatesToDownload", "type": "int"}, + "number_of_updates_downloaded": {"key": "numberOfUpdatesDownloaded", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.download_phase = None self.percent_complete = None self.total_bytes_to_download = None @@ -3475,7 +3745,7 @@ def __init__( self.number_of_updates_downloaded = None -class UpdateInstallProgress(msrest.serialization.Model): +class UpdateInstallProgress(_serialization.Model): """Progress details during installation of updates. Variables are only populated by the server, and will be ignored when sending a request. @@ -3489,28 +3759,26 @@ class UpdateInstallProgress(msrest.serialization.Model): """ _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, + "percent_complete": {"readonly": True}, + "number_of_updates_to_install": {"readonly": True}, + "number_of_updates_installed": {"readonly": True}, } _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "number_of_updates_to_install": {"key": "numberOfUpdatesToInstall", "type": "int"}, + "number_of_updates_installed": {"key": "numberOfUpdatesInstalled", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.percent_complete = None self.number_of_updates_to_install = None self.number_of_updates_installed = None -class UpdateSummary(ARMBaseModel): +class UpdateSummary(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Details about ongoing updates and availability of updates on the device. Variables are only populated by the server, and will be ignored when sending a request. @@ -3521,15 +3789,15 @@ class UpdateSummary(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed + :ivar device_version_number: The current version of the device in format: 1.2.17312.13.",. + :vartype device_version_number: str + :ivar friendly_device_version_name: The current version of the device in text format. + :vartype friendly_device_version_name: str + :ivar device_last_scanned_date_time: The last time when a scan was done on the device. + :vartype device_last_scanned_date_time: ~datetime.datetime + :ivar last_completed_scan_job_date_time: The time when the last scan job was completed (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime + :vartype last_completed_scan_job_date_time: ~datetime.datetime :ivar last_completed_download_job_date_time: The time when the last Download job was completed (success/cancelled/failed) on the appliance. :vartype last_completed_download_job_date_time: ~datetime.datetime @@ -3544,11 +3812,11 @@ class UpdateSummary(ARMBaseModel): :ivar total_number_of_updates_pending_install: The total number of items pending install. :vartype total_number_of_updates_pending_install: int :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". + :ivar ongoing_update_operation: The current update operation. Known values are: "None", "Scan", + "Download", and "Install". :vartype ongoing_update_operation: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UpdateOperation :ivar in_progress_download_job_id: The job ID of the download job in progress. @@ -3568,45 +3836,63 @@ class UpdateSummary(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_completed_download_job_date_time": {"readonly": True}, + "last_completed_install_job_date_time": {"readonly": True}, + "total_number_of_updates_available": {"readonly": True}, + "total_number_of_updates_pending_download": {"readonly": True}, + "total_number_of_updates_pending_install": {"readonly": True}, + "reboot_behavior": {"readonly": True}, + "ongoing_update_operation": {"readonly": True}, + "in_progress_download_job_id": {"readonly": True}, + "in_progress_install_job_id": {"readonly": True}, + "in_progress_download_job_started_date_time": {"readonly": True}, + "in_progress_install_job_started_date_time": {"readonly": True}, + "update_titles": {"readonly": True}, + "total_update_size_in_bytes": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_version_number": {"key": "properties.deviceVersionNumber", "type": "str"}, + "friendly_device_version_name": {"key": "properties.friendlyDeviceVersionName", "type": "str"}, + "device_last_scanned_date_time": {"key": "properties.deviceLastScannedDateTime", "type": "iso-8601"}, + "last_completed_scan_job_date_time": {"key": "properties.lastCompletedScanJobDateTime", "type": "iso-8601"}, + "last_completed_download_job_date_time": { + "key": "properties.lastCompletedDownloadJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_date_time": { + "key": "properties.lastCompletedInstallJobDateTime", + "type": "iso-8601", + }, + "total_number_of_updates_available": {"key": "properties.totalNumberOfUpdatesAvailable", "type": "int"}, + "total_number_of_updates_pending_download": { + "key": "properties.totalNumberOfUpdatesPendingDownload", + "type": "int", + }, + "total_number_of_updates_pending_install": { + "key": "properties.totalNumberOfUpdatesPendingInstall", + "type": "int", + }, + "reboot_behavior": {"key": "properties.rebootBehavior", "type": "str"}, + "ongoing_update_operation": {"key": "properties.ongoingUpdateOperation", "type": "str"}, + "in_progress_download_job_id": {"key": "properties.inProgressDownloadJobId", "type": "str"}, + "in_progress_install_job_id": {"key": "properties.inProgressInstallJobId", "type": "str"}, + "in_progress_download_job_started_date_time": { + "key": "properties.inProgressDownloadJobStartedDateTime", + "type": "iso-8601", + }, + "in_progress_install_job_started_date_time": { + "key": "properties.inProgressInstallJobStartedDateTime", + "type": "iso-8601", + }, + "update_titles": {"key": "properties.updateTitles", "type": "[str]"}, + "total_update_size_in_bytes": {"key": "properties.totalUpdateSizeInBytes", "type": "float"}, } def __init__( @@ -3618,7 +3904,18 @@ def __init__( last_completed_scan_job_date_time: Optional[datetime.datetime] = None, **kwargs ): - super(UpdateSummary, self).__init__(**kwargs) + """ + :keyword device_version_number: The current version of the device in format: 1.2.17312.13.",. + :paramtype device_version_number: str + :keyword friendly_device_version_name: The current version of the device in text format. + :paramtype friendly_device_version_name: str + :keyword device_last_scanned_date_time: The last time when a scan was done on the device. + :paramtype device_last_scanned_date_time: ~datetime.datetime + :keyword last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :paramtype last_completed_scan_job_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.device_version_number = device_version_number self.friendly_device_version_name = friendly_device_version_name self.device_last_scanned_date_time = device_last_scanned_date_time @@ -3638,48 +3935,57 @@ def __init__( self.total_update_size_in_bytes = None -class UploadCertificateRequest(msrest.serialization.Model): +class UploadCertificateRequest(_serialization.Model): """The upload certificate request. All required parameters must be populated in order to send to Azure. - :param authentication_type: The authentication type. Possible values include: "Invalid", + :ivar authentication_type: The authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type authentication_type: str or + :vartype authentication_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str + :ivar certificate: The base64 encoded certificate raw data. Required. + :vartype certificate: str """ _validation = { - 'certificate': {'required': True}, + "certificate": {"required": True}, } _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "certificate": {"key": "properties.certificate", "type": "str"}, } def __init__( self, *, certificate: str, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs ): - super(UploadCertificateRequest, self).__init__(**kwargs) + """ + :keyword authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype authentication_type: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AuthenticationType + :keyword certificate: The base64 encoded certificate raw data. Required. + :paramtype certificate: str + """ + super().__init__(**kwargs) self.authentication_type = authentication_type self.certificate = certificate -class UploadCertificateResponse(msrest.serialization.Model): +class UploadCertificateResponse(_serialization.Model): """The upload registration certificate response. Variables are only populated by the server, and will be ignored when sending a request. - :param auth_type: Specifies authentication type. Possible values include: "Invalid", + :ivar auth_type: Specifies authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AuthenticationType + :vartype auth_type: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AuthenticationType :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. :vartype resource_id: str :ivar aad_authority: Azure Active Directory tenant authority. @@ -3698,33 +4004,34 @@ class UploadCertificateResponse(msrest.serialization.Model): """ _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, + "resource_id": {"readonly": True}, + "aad_authority": {"readonly": True}, + "aad_tenant_id": {"readonly": True}, + "service_principal_client_id": {"readonly": True}, + "service_principal_object_id": {"readonly": True}, + "azure_management_endpoint_audience": {"readonly": True}, + "aad_audience": {"readonly": True}, } _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - *, - auth_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) + "auth_type": {"key": "authType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "aad_authority": {"key": "aadAuthority", "type": "str"}, + "aad_tenant_id": {"key": "aadTenantId", "type": "str"}, + "service_principal_client_id": {"key": "servicePrincipalClientId", "type": "str"}, + "service_principal_object_id": {"key": "servicePrincipalObjectId", "type": "str"}, + "azure_management_endpoint_audience": {"key": "azureManagementEndpointAudience", "type": "str"}, + "aad_audience": {"key": "aadAudience", "type": "str"}, + } + + def __init__(self, *, auth_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs): + """ + :keyword auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype auth_type: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AuthenticationType + """ + super().__init__(**kwargs) self.auth_type = auth_type self.resource_id = None self.aad_authority = None @@ -3748,83 +4055,93 @@ class User(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encrypted_password: The password details. - :type encrypted_password: + :ivar encrypted_password: The password details. + :vartype encrypted_password: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret :ivar share_access_rights: List of shares that the user has rights on. This field should not be specified during user creation. :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessRight] - :param user_type: Required. Type of the user. Possible values include: "Share", - "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UserType + :ivar user_type: Type of the user. Required. Known values are: "Share", "LocalManagement", and + "ARM". + :vartype user_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UserType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'share_access_rights': {'readonly': True}, - 'user_type': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "share_access_rights": {"readonly": True}, + "user_type": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encrypted_password": {"key": "properties.encryptedPassword", "type": "AsymmetricEncryptedSecret"}, + "share_access_rights": {"key": "properties.shareAccessRights", "type": "[ShareAccessRight]"}, + "user_type": {"key": "properties.userType", "type": "str"}, } def __init__( self, *, - user_type: Union[str, "UserType"], - encrypted_password: Optional["AsymmetricEncryptedSecret"] = None, + user_type: Union[str, "_models.UserType"], + encrypted_password: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs ): - super(User, self).__init__(**kwargs) + """ + :keyword encrypted_password: The password details. + :paramtype encrypted_password: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.AsymmetricEncryptedSecret + :keyword user_type: Type of the user. Required. Known values are: "Share", "LocalManagement", + and "ARM". + :paramtype user_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UserType + """ + super().__init__(**kwargs) self.encrypted_password = encrypted_password self.share_access_rights = None self.user_type = user_type -class UserAccessRight(msrest.serialization.Model): +class UserAccessRight(_serialization.Model): """The mapping between a particular user and the access type on the SMB share. All required parameters must be populated in order to send to Azure. - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessType + :ivar user_id: User ID (already existing in the device). Required. + :vartype user_id: str + :ivar access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessType """ _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, + "user_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - user_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) + "user_id": {"key": "userId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, user_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword user_id: User ID (already existing in the device). Required. + :paramtype user_id: str + :keyword access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :paramtype access_type: str or + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareAccessType + """ + super().__init__(**kwargs) self.user_id = user_id self.access_type = access_type -class UserList(msrest.serialization.Model): +class UserList(_serialization.Model): """Collection of users. Variables are only populated by the server, and will be ignored when sending a request. @@ -3836,19 +4153,17 @@ class UserList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[User]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/__init__.py index 94a6a27f766b..a5b67b917b67 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/__init__.py @@ -24,22 +24,28 @@ from ._users_operations import UsersOperations from ._skus_operations import SkusOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', - 'SkusOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", + "SkusOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_alerts_operations.py index 1c1362f56b1f..2e3d5bf20d54 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,204 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class AlertsOperations(object): - """AlertsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_by_data_box_edge_device_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,72 +212,75 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_available_skus_operations.py index 01d14b89253e..c72d6d2980c2 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,158 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } -class AvailableSkusOperations(object): - """AvailableSkusOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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 AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeSkuList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,7 +166,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_bandwidth_schedules_operations.py index b827a2edab30..95f1e381b975 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,278 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class BandwidthSchedulesOperations(object): - """BandwidthSchedulesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BandwidthSchedulesList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +286,130 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BandwidthSchedule" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BandwidthSchedule"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +418,219 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BandwidthSchedule"] + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +640,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_containers_operations.py index a73b349932d3..51cd77c09633 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,342 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_storage_account_request( + device_name: str, storage_account_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ContainersOperations(object): - """ContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_storage_account( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ContainerList"] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,124 +350,139 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Container" + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Container"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -249,55 +491,154 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Container"] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Container or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -305,80 +646,77 @@ def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -388,121 +726,120 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -512,81 +849,81 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace def begin_refresh( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_devices_operations.py index 884339fc563c..2e51f34932df 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,611 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", + ) # 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"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_download_updates_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_extended_information_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_install_updates_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_settings_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_scan_for_updates_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_security_settings_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + 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, **kwargs) + + +def build_get_update_summary_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class DevicesOperations(object): - """DevicesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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_upload_certificate_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_subscription( - self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,75 +619,92 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + @distributed_trace def list_by_resource_group( - self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,230 +713,335 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } def _create_or_update_initial( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. - :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -425,174 +1051,250 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def update( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDevicePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevicePatch or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - def _download_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -602,168 +1304,176 @@ def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } - def begin_download_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_download_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._download_updates_initial( + raw_result = self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace def get_extended_information( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - def _install_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -773,168 +1483,176 @@ def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } - def begin_install_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_install_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._install_updates_initial( + raw_result = self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + + @distributed_trace def get_network_settings( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkSettings" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - def _scan_for_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -944,115 +1662,128 @@ def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def begin_scan_for_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_scan_for_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._scan_for_updates_initial( + raw_result = self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def _create_or_update_security_settings_initial( + def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1062,202 +1793,361 @@ def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload def begin_create_or_update_security_settings( self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.SecuritySettings or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_security_settings_initial( + raw_result = self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def get_update_summary( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateSummary" - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @distributed_trace + def get_update_summary(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload def upload_certificate( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.UploadCertificateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.UploadCertificateResponse" + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_jobs_operations.py index 1eac9900ad85..c7087c2e0bd2 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class JobsOperations(object): - """JobsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_nodes_operations.py index 5e672337610e..7bf689acce41 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,170 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class NodesOperations(object): - """NodesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NodeList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +178,8 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_operations.py index 75fddac15261..efed29b83ac0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataBoxEdge/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +160,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_operations_status_operations.py index b0b1a13be6d9..c4176ef32525 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class OperationsStatusOperations(object): - """OperationsStatusOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_orders_operations.py index 367baeaac122..788320a0023b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,274 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request(device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_delete_request( + device_name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") -class OrdersOperations(object): - """OrdersOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OrderList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,112 +282,123 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Order" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } def _create_or_update_initial( - self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Order"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,122 +407,204 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Order"] + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,71 +614,73 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_roles_operations.py index 8b933caa218d..b367913c5ed9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RolesOperations(object): - """RolesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +285,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Role" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Role"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +412,207 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Role"] + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +622,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_shares_operations.py index 3a44b369eb61..e62b4e256eb8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,313 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class SharesOperations(object): - """SharesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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 SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ShareList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +321,127 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Share" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Share"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +450,213 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Share"] + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,114 +666,114 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -488,76 +783,76 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } - def begin_refresh( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_refresh(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_skus_operations.py index ccd712a63908..518ec4b04b6b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,164 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } -class SkusOperations(object): - """SkusOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SkuInformationList"] + 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 list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.ResourceTypeSku"]: """List all the available Skus in the region and information related to them. List all the available Skus in the region and information related to them. - :param filter: Specify $filter='location eq :code:``' to filter on location. + :param filter: Specify $filter='location eq :code:``' to filter on location. Default + value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkuInformationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.SkuInformationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourceTypeSku or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.ResourceTypeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuInformationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.SkuInformationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SkuInformationList', pipeline_response) + deserialized = self._deserialize("SkuInformationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,7 +172,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/skus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_storage_account_credentials_operations.py index 1e20a36ee799..898516958b0c 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,281 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class StorageAccountCredentialsOperations(object): - """StorageAccountCredentialsOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountCredentialList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,116 +289,132 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountCredential" + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccountCredential"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -237,127 +423,221 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccountCredential"] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -367,74 +647,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_storage_accounts_operations.py index 1c5a65220bb0..1274802eecdd 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,280 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, storage_account_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, storage_account_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, storage_account_name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts in a Data Box Edge/Data Box Gateway device. Lists all the storage accounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +288,134 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccount" + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccount"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +424,225 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccount"] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -371,74 +652,76 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_triggers_operations.py index 52c027b9dae5..8db91e8cea69 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,284 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TriggersOperations(object): - """TriggersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TriggerList"] + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +292,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Trigger" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Trigger"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,127 +419,210 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Trigger"] + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Trigger or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +632,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_users_operations.py index ab9302f39c18..6dfd5f75ee70 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,115 +6,283 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class UsersOperations(object): - """UsersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserList"] + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='UserType eq :code:``' to filter on user type property. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,116 +291,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.User"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -240,128 +418,210 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.User"] + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +631,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/__init__.py index e63196b6b98f..d2bcf6a47896 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/__init__.py @@ -7,10 +7,20 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_configuration.py index a5b47c318d7a..57c81d6ea344 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_configuration.py @@ -6,65 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", "2020-09-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-09-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_data_box_edge_management_client.py index d17c09ae83c7..fa01723a7464 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_data_box_edge_management_client.py @@ -6,41 +6,42 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import AddonsOperations -from .operations import MonitoringConfigOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from . import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations @@ -52,13 +53,15 @@ class DataBoxEdgeManagementClient(object): :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2020_09_01.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2020_09_01.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2020_09_01.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2020_09_01.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2020_09_01.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2020_09_01.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2020_09_01.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2020_09_01.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -66,109 +69,108 @@ class DataBoxEdgeManagementClient(object): :ivar addons: AddonsOperations operations :vartype addons: azure.mgmt.databoxedge.v2020_09_01.operations.AddonsOperations :ivar monitoring_config: MonitoringConfigOperations operations - :vartype monitoring_config: azure.mgmt.databoxedge.v2020_09_01.operations.MonitoringConfigOperations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2020_09_01.operations.MonitoringConfigOperations :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2020_09_01.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2020_09_01.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2020_09_01.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2020_09_01.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2020_09_01.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations :vartype containers: azure.mgmt.databoxedge.v2020_09_01.operations.ContainersOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2020_09_01.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2020_09_01.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) self.monitoring_config = MonitoringConfigOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None + + 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) -> None: self._client.close() - def __enter__(self): - # type: () -> DataBoxEdgeManagementClient + def __enter__(self) -> "DataBoxEdgeManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_metadata.json b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_metadata.json index 95fd599d3039..12db53f854d5 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_metadata.json +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_metadata.json @@ -5,25 +5,25 @@ "name": "DataBoxEdgeManagementClient", "filename": "_data_box_edge_management_client", "description": "The DataBoxEdge Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription ID.", + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription ID.", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=None, # type: Optional[str]", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -117,4 +116,4 @@ "triggers": "TriggersOperations", "users": "UsersOperations" } -} \ No newline at end of file +} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_vendor.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_version.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/__init__.py index c33d46ee91d8..fcb8775eaa10 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_configuration.py index ee8f3c8f4c5e..938586b7fd4f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_configuration.py @@ -6,61 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", "2020-09-01") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-09-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_data_box_edge_management_client.py index dc7f95bad1ec..0eb573abf6bd 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_data_box_edge_management_client.py @@ -6,57 +6,63 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import AddonsOperations -from .operations import MonitoringConfigOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .. import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.databoxedge.v2020_09_01.aio.operations.Operations :ivar available_skus: AvailableSkusOperations operations - :vartype available_skus: azure.mgmt.databoxedge.v2020_09_01.aio.operations.AvailableSkusOperations + :vartype available_skus: + azure.mgmt.databoxedge.v2020_09_01.aio.operations.AvailableSkusOperations :ivar devices: DevicesOperations operations :vartype devices: azure.mgmt.databoxedge.v2020_09_01.aio.operations.DevicesOperations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2020_09_01.aio.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2020_09_01.aio.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2020_09_01.aio.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2020_09_01.aio.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2020_09_01.aio.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2020_09_01.aio.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2020_09_01.aio.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2020_09_01.aio.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -64,97 +70,101 @@ class DataBoxEdgeManagementClient(object): :ivar addons: AddonsOperations operations :vartype addons: azure.mgmt.databoxedge.v2020_09_01.aio.operations.AddonsOperations :ivar monitoring_config: MonitoringConfigOperations operations - :vartype monitoring_config: azure.mgmt.databoxedge.v2020_09_01.aio.operations.MonitoringConfigOperations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2020_09_01.aio.operations.MonitoringConfigOperations :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2020_09_01.aio.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2020_09_01.aio.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2020_09_01.aio.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2020_09_01.aio.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2020_09_01.aio.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations :vartype containers: azure.mgmt.databoxedge.v2020_09_01.aio.operations.ContainersOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2020_09_01.aio.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2020_09_01.aio.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) self.monitoring_config = MonitoringConfigOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/__init__.py index d70057be6458..febac852eb27 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/__init__.py @@ -25,23 +25,29 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'AddonsOperations', - 'MonitoringConfigOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_addons_operations.py index e2da3a2ef7d4..470e20258951 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_addons_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,109 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._addons_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_role_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AddonsOperations: - """AddonsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`addons` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_role( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AddonList"]: + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Addon"]: """Lists all the addons configured in the role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AddonList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_role.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -116,76 +152,79 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_role.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + + @distributed_trace_async async def get( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Addon": + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: """Gets a specific addon by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } async def _create_or_update_initial( self, @@ -193,43 +232,53 @@ async def _create_or_update_initial( role_name: str, addon_name: str, resource_group_name: str, - addon: "_models.Addon", - **kwargs - ) -> Optional["_models.Addon"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Addon"]] + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(addon, 'Addon') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -238,52 +287,143 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload async def begin_create_or_update( self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, - addon: "_models.Addon", - **kwargs - ) -> AsyncLROPoller["_models.Addon"]: + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: """Create or update a addon. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param addon: The addon properties. + :param addon: The addon properties. Required. :type addon: ~azure.mgmt.databoxedge.v2020_09_01.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Addon or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2020_09_01.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -291,79 +431,75 @@ async def begin_create_or_update( addon_name=addon_name, resource_group_name=resource_group_name, addon=addon, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -373,78 +509,79 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the addon on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, addon_name=addon_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_alerts_operations.py index 5b134957aeda..139d27b7189f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._alerts_operations import build_get_request, build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AlertsOperations: - """AlertsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AlertList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,71 +142,73 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Alert": + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_available_skus_operations.py index cb20cc6d9af5..cb0cedcb97eb 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._available_skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AvailableSkusOperations: - """AvailableSkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeSkuList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +135,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_bandwidth_schedules_operations.py index dd7b1aab3acf..e7fb079fe9d1 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._bandwidth_schedules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BandwidthSchedulesOperations: - """BandwidthSchedulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.BandwidthSchedulesList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.BandwidthSchedule": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> Optional["_models.BandwidthSchedule"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +279,215 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> AsyncLROPoller["_models.BandwidthSchedule"]: + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +497,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_containers_operations.py index a1cc1ba15971..a01bc916ca2d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._containers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_storage_account_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainersOperations: - """ContainersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_storage_account( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ContainerList"]: + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,78 +155,81 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Container": + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } async def _create_or_update_initial( self, @@ -197,43 +237,53 @@ async def _create_or_update_initial( storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> Optional["_models.Container"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -242,54 +292,155 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> AsyncLROPoller["_models.Container"]: + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2020_09_01.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Container or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Container] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2020_09_01.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -297,79 +448,75 @@ async def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -379,119 +526,116 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -501,80 +645,79 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_devices_operations.py index a57be9277501..b39f33c4a2d0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._devices_operations import ( + build_create_or_update_request, + build_create_or_update_security_settings_request, + build_delete_request, + build_download_updates_request, + build_generate_certificate_request, + build_get_extended_information_request, + build_get_network_settings_request, + build_get_request, + build_get_update_summary_request, + build_install_updates_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_scan_for_updates_request, + build_update_extended_information_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations: - """DevicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_subscription( - self, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,74 +160,90 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,226 +252,325 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDevice": + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } async def _create_or_update_initial( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> "_models.DataBoxEdgeDevice": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> AsyncLROPoller["_models.DataBoxEdgeDevice"]: + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -415,171 +580,243 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload async def update( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDevicePatch", - **kwargs - ) -> "_models.DataBoxEdgeDevice": + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - async def _download_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -589,223 +826,234 @@ async def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def begin_download_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._download_updates_initial( + raw_result = await self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def generate_certificate( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.GenerateCertResponse": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: """Generates certificate for activation key. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenerateCertResponse, or the result of cls(response) + :return: GenerateCertResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.GenerateCertResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCertResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.generate_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateCertResponse', pipeline_response) + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate'} # type: ignore + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace_async async def get_extended_information( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - async def _install_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + async def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -815,165 +1063,172 @@ async def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def begin_install_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._install_updates_initial( + raw_result = await self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + + @distributed_trace_async async def get_network_settings( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.NetworkSettings": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - async def _scan_for_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + async def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -983,113 +1238,126 @@ async def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + @distributed_trace_async async def begin_scan_for_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._scan_for_updates_initial( + raw_result = await self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - async def _create_or_update_security_settings_initial( + async def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1099,265 +1367,493 @@ async def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload async def begin_create_or_update_security_settings( self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2020_09_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2020_09_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_security_settings_initial( + raw_result = await self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async async def update_extended_information( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDeviceExtendedInfoPatch", - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The patch object. + :param parameters: The patch object. Is either a model type or a IO type. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfoPatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDeviceExtendedInfoPatch') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation'} # type: ignore + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace_async async def get_update_summary( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.UpdateSummary": - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload async def upload_certificate( self, device_name: str, resource_group_name: str, - parameters: "_models.UploadCertificateRequest", - **kwargs - ) -> "_models.UploadCertificateResponse": + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_jobs_operations.py index 11ea6d59f07a..6dc125683737 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class JobsOperations: - """JobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_monitoring_config_operations.py index af835149a368..6512ca8aca4e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_monitoring_config_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_monitoring_config_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._monitoring_config_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringConfigOperations: - """MonitoringConfigOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.MonitoringMetricConfigurationList"]: + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MonitoringMetricConfiguration"]: """Lists metric configurations in a role. Lists metric configurations in a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 MonitoringMetricConfigurationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfigurationList', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,116 +155,130 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + @distributed_trace_async async def get( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.MonitoringMetricConfiguration": + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: """Gets a metric configuration of a role. Gets a metric configuration of a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringMetricConfiguration, or the result of cls(response) + :return: MonitoringMetricConfiguration or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } async def _create_or_update_initial( self, device_name: str, role_name: str, resource_group_name: str, - monitoring_metric_configuration: "_models.MonitoringMetricConfiguration", - **kwargs - ) -> Optional["_models.MonitoringMetricConfiguration"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MonitoringMetricConfiguration"]] + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(monitoring_metric_configuration, 'MonitoringMetricConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -236,127 +287,223 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload async def begin_create_or_update( self, device_name: str, role_name: str, resource_group_name: str, - monitoring_metric_configuration: "_models.MonitoringMetricConfiguration", - **kwargs - ) -> AsyncLROPoller["_models.MonitoringMetricConfiguration"]: + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: """Creates a new metric configuration or updates an existing one for a role. Creates a new metric configuration or updates an existing one for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param monitoring_metric_configuration: The metric configuration. - :type monitoring_metric_configuration: ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, monitoring_metric_configuration=monitoring_metric_configuration, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) - + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -366,75 +513,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """deletes a new metric configuration for a role. deletes a new metric configuration for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_nodes_operations.py index 951e1d5c4232..1f34712d7b54 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._nodes_operations import build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NodesOperations: - """NodesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.NodeList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +141,8 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_operations.py index 105241694868..f01852d951f0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,126 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.OperationsList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +134,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_operations_status_operations.py index 1e807137bab8..39903118a68d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,116 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations_status_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsStatusOperations: - """OperationsStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_orders_operations.py index 220286ce394f..213c88dc47af 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._orders_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_list_dc_access_code_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OrdersOperations: - """OrdersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.OrderList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,110 +152,119 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Order": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } async def _create_or_update_initial( - self, - device_name: str, - resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> Optional["_models.Order"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -226,120 +273,200 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> AsyncLROPoller["_models.Order"]: + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2020_09_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2020_09_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -349,130 +476,135 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + @distributed_trace_async async def list_dc_access_code( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DCAccessCode": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DCAccessCode: """Gets the DCAccess Code. Gets the DCAccess Code. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DCAccessCode, or the result of cls(response) + :return: DCAccessCode or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DCAccessCode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DCAccessCode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.list_dc_access_code.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DCAccessCode', pipeline_response) + deserialized = self._deserialize("DCAccessCode", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_dc_access_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode'} # type: ignore + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_roles_operations.py index 1d06b52d0b3c..019569814faa 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,141 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._roles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RolesOperations: - """RolesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.RoleList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +149,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Role": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> Optional["_models.Role"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +272,203 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> AsyncLROPoller["_models.Role"]: + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2020_09_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2020_09_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +478,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_shares_operations.py index 246846443d64..44a45f591a33 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._shares_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SharesOperations: - """SharesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ShareList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +152,123 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Share": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> Optional["_models.Share"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +277,209 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> AsyncLROPoller["_models.Share"]: + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2020_09_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2020_09_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,112 +489,112 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -477,75 +604,76 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_storage_account_credentials_operations.py index 9c11230abb8d..9f74eaea55a0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_account_credentials_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountCredentialsOperations: - """StorageAccountCredentialsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountCredentialList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,114 +152,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccountCredential": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> Optional["_models.StorageAccountCredential"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -230,125 +282,217 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccountCredential"]: + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,73 +502,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_storage_accounts_operations.py index 59b3bd05ec14..47889fe11b3d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_accounts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountsOperations: - """StorageAccountsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +151,130 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccount": + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } async def _create_or_update_initial( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +283,221 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccount"]: + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -362,73 +507,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_triggers_operations.py index 47074ae7f1c3..60ad7078f364 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._triggers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TriggersOperations: - """TriggersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.TriggerList"]: + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +153,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Trigger": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> Optional["_models.Trigger"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,125 +276,206 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> AsyncLROPoller["_models.Trigger"]: + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2020_09_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Trigger or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Trigger or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2020_09_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +485,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_users_operations.py index 7a72b497646b..db2a83e32d6d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/aio/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UsersOperations: - """UsersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.aio.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.UserList"]: + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +154,121 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.User": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - user: "_models.User", - **kwargs - ) -> Optional["_models.User"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,126 +277,206 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - user: "_models.User", - **kwargs - ) -> AsyncLROPoller["_models.User"]: + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2020_09_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2020_09_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -363,73 +486,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/__init__.py index 8b331ada40a8..52dfb236f5e9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/__init__.py @@ -6,471 +6,356 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARMBaseModel - from ._models_py3 import Addon - from ._models_py3 import AddonList - from ._models_py3 import Address - from ._models_py3 import Alert - from ._models_py3 import AlertErrorDetails - from ._models_py3 import AlertList - from ._models_py3 import ArcAddon - from ._models_py3 import AsymmetricEncryptedSecret - from ._models_py3 import Authentication - from ._models_py3 import AzureContainerInfo - from ._models_py3 import BandwidthSchedule - from ._models_py3 import BandwidthSchedulesList - from ._models_py3 import ClientAccessRight - from ._models_py3 import CloudEdgeManagementRole - from ._models_py3 import CloudErrorBody - from ._models_py3 import CniConfig - from ._models_py3 import ComputeResource - from ._models_py3 import ContactDetails - from ._models_py3 import Container - from ._models_py3 import ContainerList - from ._models_py3 import DCAccessCode - from ._models_py3 import DataBoxEdgeDevice - from ._models_py3 import DataBoxEdgeDeviceExtendedInfo - from ._models_py3 import DataBoxEdgeDeviceExtendedInfoPatch - from ._models_py3 import DataBoxEdgeDeviceList - from ._models_py3 import DataBoxEdgeDevicePatch - from ._models_py3 import DataBoxEdgeMoveRequest - from ._models_py3 import DataBoxEdgeSku - from ._models_py3 import DataBoxEdgeSkuList - from ._models_py3 import EdgeProfile - from ._models_py3 import EdgeProfilePatch - from ._models_py3 import EdgeProfileSubscription - from ._models_py3 import EdgeProfileSubscriptionPatch - from ._models_py3 import EtcdInfo - from ._models_py3 import FileEventTrigger - from ._models_py3 import FileSourceInfo - from ._models_py3 import GenerateCertResponse - from ._models_py3 import ImageRepositoryCredential - from ._models_py3 import IoTAddon - from ._models_py3 import IoTDeviceInfo - from ._models_py3 import IoTEdgeAgentInfo - from ._models_py3 import IoTRole - from ._models_py3 import Ipv4Config - from ._models_py3 import Ipv6Config - from ._models_py3 import Job - from ._models_py3 import JobErrorDetails - from ._models_py3 import JobErrorItem - from ._models_py3 import KubernetesClusterInfo - from ._models_py3 import KubernetesIPConfiguration - from ._models_py3 import KubernetesRole - from ._models_py3 import KubernetesRoleCompute - from ._models_py3 import KubernetesRoleNetwork - from ._models_py3 import KubernetesRoleResources - from ._models_py3 import KubernetesRoleStorage - from ._models_py3 import KubernetesRoleStorageClassInfo - from ._models_py3 import LoadBalancerConfig - from ._models_py3 import MECRole - from ._models_py3 import MetricConfiguration - from ._models_py3 import MetricCounter - from ._models_py3 import MetricCounterSet - from ._models_py3 import MetricDimension - from ._models_py3 import MetricDimensionV1 - from ._models_py3 import MetricSpecificationV1 - from ._models_py3 import MonitoringMetricConfiguration - from ._models_py3 import MonitoringMetricConfigurationList - from ._models_py3 import MountPointMap - from ._models_py3 import NetworkAdapter - from ._models_py3 import NetworkAdapterPosition - from ._models_py3 import NetworkSettings - from ._models_py3 import Node - from ._models_py3 import NodeInfo - from ._models_py3 import NodeList - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import Order - from ._models_py3 import OrderList - from ._models_py3 import OrderStatus - from ._models_py3 import PeriodicTimerEventTrigger - from ._models_py3 import PeriodicTimerSourceInfo - from ._models_py3 import RefreshDetails - from ._models_py3 import ResourceIdentity - from ._models_py3 import ResourceMoveDetails - from ._models_py3 import ResourceTypeSku - from ._models_py3 import Role - from ._models_py3 import RoleList - from ._models_py3 import RoleSinkInfo - from ._models_py3 import SecuritySettings - from ._models_py3 import ServiceSpecification - from ._models_py3 import Share - from ._models_py3 import ShareAccessRight - from ._models_py3 import ShareList - from ._models_py3 import Sku - from ._models_py3 import SkuCost - from ._models_py3 import SkuInformation - from ._models_py3 import SkuInformationList - from ._models_py3 import SkuLocationInfo - from ._models_py3 import StorageAccount - from ._models_py3 import StorageAccountCredential - from ._models_py3 import StorageAccountCredentialList - from ._models_py3 import StorageAccountList - from ._models_py3 import SubscriptionRegisteredFeatures - from ._models_py3 import SymmetricKey - from ._models_py3 import SystemData - from ._models_py3 import TrackingInfo - from ._models_py3 import Trigger - from ._models_py3 import TriggerList - from ._models_py3 import UpdateDownloadProgress - from ._models_py3 import UpdateInstallProgress - from ._models_py3 import UpdateSummary - from ._models_py3 import UploadCertificateRequest - from ._models_py3 import UploadCertificateResponse - from ._models_py3 import User - from ._models_py3 import UserAccessRight - from ._models_py3 import UserList -except (SyntaxError, ImportError): - from ._models import ARMBaseModel # type: ignore - from ._models import Addon # type: ignore - from ._models import AddonList # type: ignore - from ._models import Address # type: ignore - from ._models import Alert # type: ignore - from ._models import AlertErrorDetails # type: ignore - from ._models import AlertList # type: ignore - from ._models import ArcAddon # type: ignore - from ._models import AsymmetricEncryptedSecret # type: ignore - from ._models import Authentication # type: ignore - from ._models import AzureContainerInfo # type: ignore - from ._models import BandwidthSchedule # type: ignore - from ._models import BandwidthSchedulesList # type: ignore - from ._models import ClientAccessRight # type: ignore - from ._models import CloudEdgeManagementRole # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import CniConfig # type: ignore - from ._models import ComputeResource # type: ignore - from ._models import ContactDetails # type: ignore - from ._models import Container # type: ignore - from ._models import ContainerList # type: ignore - from ._models import DCAccessCode # type: ignore - from ._models import DataBoxEdgeDevice # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfo # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfoPatch # type: ignore - from ._models import DataBoxEdgeDeviceList # type: ignore - from ._models import DataBoxEdgeDevicePatch # type: ignore - from ._models import DataBoxEdgeMoveRequest # type: ignore - from ._models import DataBoxEdgeSku # type: ignore - from ._models import DataBoxEdgeSkuList # type: ignore - from ._models import EdgeProfile # type: ignore - from ._models import EdgeProfilePatch # type: ignore - from ._models import EdgeProfileSubscription # type: ignore - from ._models import EdgeProfileSubscriptionPatch # type: ignore - from ._models import EtcdInfo # type: ignore - from ._models import FileEventTrigger # type: ignore - from ._models import FileSourceInfo # type: ignore - from ._models import GenerateCertResponse # type: ignore - from ._models import ImageRepositoryCredential # type: ignore - from ._models import IoTAddon # type: ignore - from ._models import IoTDeviceInfo # type: ignore - from ._models import IoTEdgeAgentInfo # type: ignore - from ._models import IoTRole # type: ignore - from ._models import Ipv4Config # type: ignore - from ._models import Ipv6Config # type: ignore - from ._models import Job # type: ignore - from ._models import JobErrorDetails # type: ignore - from ._models import JobErrorItem # type: ignore - from ._models import KubernetesClusterInfo # type: ignore - from ._models import KubernetesIPConfiguration # type: ignore - from ._models import KubernetesRole # type: ignore - from ._models import KubernetesRoleCompute # type: ignore - from ._models import KubernetesRoleNetwork # type: ignore - from ._models import KubernetesRoleResources # type: ignore - from ._models import KubernetesRoleStorage # type: ignore - from ._models import KubernetesRoleStorageClassInfo # type: ignore - from ._models import LoadBalancerConfig # type: ignore - from ._models import MECRole # type: ignore - from ._models import MetricConfiguration # type: ignore - from ._models import MetricCounter # type: ignore - from ._models import MetricCounterSet # type: ignore - from ._models import MetricDimension # type: ignore - from ._models import MetricDimensionV1 # type: ignore - from ._models import MetricSpecificationV1 # type: ignore - from ._models import MonitoringMetricConfiguration # type: ignore - from ._models import MonitoringMetricConfigurationList # type: ignore - from ._models import MountPointMap # type: ignore - from ._models import NetworkAdapter # type: ignore - from ._models import NetworkAdapterPosition # type: ignore - from ._models import NetworkSettings # type: ignore - from ._models import Node # type: ignore - from ._models import NodeInfo # type: ignore - from ._models import NodeList # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import Order # type: ignore - from ._models import OrderList # type: ignore - from ._models import OrderStatus # type: ignore - from ._models import PeriodicTimerEventTrigger # type: ignore - from ._models import PeriodicTimerSourceInfo # type: ignore - from ._models import RefreshDetails # type: ignore - from ._models import ResourceIdentity # type: ignore - from ._models import ResourceMoveDetails # type: ignore - from ._models import ResourceTypeSku # type: ignore - from ._models import Role # type: ignore - from ._models import RoleList # type: ignore - from ._models import RoleSinkInfo # type: ignore - from ._models import SecuritySettings # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Share # type: ignore - from ._models import ShareAccessRight # type: ignore - from ._models import ShareList # type: ignore - from ._models import Sku # type: ignore - from ._models import SkuCost # type: ignore - from ._models import SkuInformation # type: ignore - from ._models import SkuInformationList # type: ignore - from ._models import SkuLocationInfo # type: ignore - from ._models import StorageAccount # type: ignore - from ._models import StorageAccountCredential # type: ignore - from ._models import StorageAccountCredentialList # type: ignore - from ._models import StorageAccountList # type: ignore - from ._models import SubscriptionRegisteredFeatures # type: ignore - from ._models import SymmetricKey # type: ignore - from ._models import SystemData # type: ignore - from ._models import TrackingInfo # type: ignore - from ._models import Trigger # type: ignore - from ._models import TriggerList # type: ignore - from ._models import UpdateDownloadProgress # type: ignore - from ._models import UpdateInstallProgress # type: ignore - from ._models import UpdateSummary # type: ignore - from ._models import UploadCertificateRequest # type: ignore - from ._models import UploadCertificateResponse # type: ignore - from ._models import User # type: ignore - from ._models import UserAccessRight # type: ignore - from ._models import UserList # type: ignore +from ._models_py3 import ARMBaseModel +from ._models_py3 import Addon +from ._models_py3 import AddonList +from ._models_py3 import Address +from ._models_py3 import Alert +from ._models_py3 import AlertErrorDetails +from ._models_py3 import AlertList +from ._models_py3 import ArcAddon +from ._models_py3 import AsymmetricEncryptedSecret +from ._models_py3 import Authentication +from ._models_py3 import AzureContainerInfo +from ._models_py3 import BandwidthSchedule +from ._models_py3 import BandwidthSchedulesList +from ._models_py3 import ClientAccessRight +from ._models_py3 import CloudEdgeManagementRole +from ._models_py3 import CloudErrorBody +from ._models_py3 import CniConfig +from ._models_py3 import ComputeResource +from ._models_py3 import ContactDetails +from ._models_py3 import Container +from ._models_py3 import ContainerList +from ._models_py3 import DCAccessCode +from ._models_py3 import DataBoxEdgeDevice +from ._models_py3 import DataBoxEdgeDeviceExtendedInfo +from ._models_py3 import DataBoxEdgeDeviceExtendedInfoPatch +from ._models_py3 import DataBoxEdgeDeviceList +from ._models_py3 import DataBoxEdgeDevicePatch +from ._models_py3 import DataBoxEdgeMoveRequest +from ._models_py3 import DataBoxEdgeSku +from ._models_py3 import DataBoxEdgeSkuList +from ._models_py3 import EdgeProfile +from ._models_py3 import EdgeProfilePatch +from ._models_py3 import EdgeProfileSubscription +from ._models_py3 import EdgeProfileSubscriptionPatch +from ._models_py3 import EtcdInfo +from ._models_py3 import FileEventTrigger +from ._models_py3 import FileSourceInfo +from ._models_py3 import GenerateCertResponse +from ._models_py3 import ImageRepositoryCredential +from ._models_py3 import IoTAddon +from ._models_py3 import IoTDeviceInfo +from ._models_py3 import IoTEdgeAgentInfo +from ._models_py3 import IoTRole +from ._models_py3 import Ipv4Config +from ._models_py3 import Ipv6Config +from ._models_py3 import Job +from ._models_py3 import JobErrorDetails +from ._models_py3 import JobErrorItem +from ._models_py3 import KubernetesClusterInfo +from ._models_py3 import KubernetesIPConfiguration +from ._models_py3 import KubernetesRole +from ._models_py3 import KubernetesRoleCompute +from ._models_py3 import KubernetesRoleNetwork +from ._models_py3 import KubernetesRoleResources +from ._models_py3 import KubernetesRoleStorage +from ._models_py3 import KubernetesRoleStorageClassInfo +from ._models_py3 import LoadBalancerConfig +from ._models_py3 import MECRole +from ._models_py3 import MetricConfiguration +from ._models_py3 import MetricCounter +from ._models_py3 import MetricCounterSet +from ._models_py3 import MetricDimension +from ._models_py3 import MetricDimensionV1 +from ._models_py3 import MetricSpecificationV1 +from ._models_py3 import MonitoringMetricConfiguration +from ._models_py3 import MonitoringMetricConfigurationList +from ._models_py3 import MountPointMap +from ._models_py3 import NetworkAdapter +from ._models_py3 import NetworkAdapterPosition +from ._models_py3 import NetworkSettings +from ._models_py3 import Node +from ._models_py3 import NodeInfo +from ._models_py3 import NodeList +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import Order +from ._models_py3 import OrderList +from ._models_py3 import OrderStatus +from ._models_py3 import PeriodicTimerEventTrigger +from ._models_py3 import PeriodicTimerSourceInfo +from ._models_py3 import RefreshDetails +from ._models_py3 import ResourceIdentity +from ._models_py3 import ResourceMoveDetails +from ._models_py3 import ResourceTypeSku +from ._models_py3 import Role +from ._models_py3 import RoleList +from ._models_py3 import RoleSinkInfo +from ._models_py3 import SecuritySettings +from ._models_py3 import ServiceSpecification +from ._models_py3 import Share +from ._models_py3 import ShareAccessRight +from ._models_py3 import ShareList +from ._models_py3 import Sku +from ._models_py3 import SkuCost +from ._models_py3 import SkuInformation +from ._models_py3 import SkuInformationList +from ._models_py3 import SkuLocationInfo +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCredential +from ._models_py3 import StorageAccountCredentialList +from ._models_py3 import StorageAccountList +from ._models_py3 import SubscriptionRegisteredFeatures +from ._models_py3 import SymmetricKey +from ._models_py3 import SystemData +from ._models_py3 import TrackingInfo +from ._models_py3 import Trigger +from ._models_py3 import TriggerList +from ._models_py3 import UpdateDownloadProgress +from ._models_py3 import UpdateInstallProgress +from ._models_py3 import UpdateSummary +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UploadCertificateResponse +from ._models_py3 import User +from ._models_py3 import UserAccessRight +from ._models_py3 import UserList -from ._data_box_edge_management_client_enums import ( - AccountType, - AddonState, - AddonType, - AlertSeverity, - AuthenticationType, - AzureContainerDataFormat, - ClientPermissionType, - ContainerStatus, - CreatedByType, - DataBoxEdgeDeviceKind, - DataBoxEdgeDeviceStatus, - DataPolicy, - DayOfWeek, - DeviceType, - DownloadPhase, - EncryptionAlgorithm, - HostPlatformType, - InstallRebootBehavior, - JobStatus, - JobType, - KubernetesNodeType, - KubernetesState, - MetricAggregationType, - MetricCategory, - MetricUnit, - MonitoringStatus, - MountType, - MsiIdentityType, - NetworkAdapterDHCPStatus, - NetworkAdapterRDMAStatus, - NetworkAdapterStatus, - NetworkGroup, - NodeStatus, - OrderState, - PlatformType, - PosixComplianceStatus, - ResourceMoveStatus, - RoleStatus, - RoleTypes, - SSLStatus, - ShareAccessProtocol, - ShareAccessType, - ShareStatus, - ShipmentType, - SkuAvailability, - SkuName, - SkuSignupOption, - SkuTier, - SkuVersion, - StorageAccountStatus, - SubscriptionState, - TimeGrain, - TriggerEventType, - UpdateOperation, - UpdateOperationStage, - UserType, -) +from ._data_box_edge_management_client_enums import AccountType +from ._data_box_edge_management_client_enums import AddonState +from ._data_box_edge_management_client_enums import AddonType +from ._data_box_edge_management_client_enums import AlertSeverity +from ._data_box_edge_management_client_enums import AuthenticationType +from ._data_box_edge_management_client_enums import AzureContainerDataFormat +from ._data_box_edge_management_client_enums import ClientPermissionType +from ._data_box_edge_management_client_enums import ContainerStatus +from ._data_box_edge_management_client_enums import CreatedByType +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceKind +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceStatus +from ._data_box_edge_management_client_enums import DataPolicy +from ._data_box_edge_management_client_enums import DayOfWeek +from ._data_box_edge_management_client_enums import DeviceType +from ._data_box_edge_management_client_enums import DownloadPhase +from ._data_box_edge_management_client_enums import EncryptionAlgorithm +from ._data_box_edge_management_client_enums import HostPlatformType +from ._data_box_edge_management_client_enums import InstallRebootBehavior +from ._data_box_edge_management_client_enums import JobStatus +from ._data_box_edge_management_client_enums import JobType +from ._data_box_edge_management_client_enums import KubernetesNodeType +from ._data_box_edge_management_client_enums import KubernetesState +from ._data_box_edge_management_client_enums import MetricAggregationType +from ._data_box_edge_management_client_enums import MetricCategory +from ._data_box_edge_management_client_enums import MetricUnit +from ._data_box_edge_management_client_enums import MonitoringStatus +from ._data_box_edge_management_client_enums import MountType +from ._data_box_edge_management_client_enums import MsiIdentityType +from ._data_box_edge_management_client_enums import NetworkAdapterDHCPStatus +from ._data_box_edge_management_client_enums import NetworkAdapterRDMAStatus +from ._data_box_edge_management_client_enums import NetworkAdapterStatus +from ._data_box_edge_management_client_enums import NetworkGroup +from ._data_box_edge_management_client_enums import NodeStatus +from ._data_box_edge_management_client_enums import OrderState +from ._data_box_edge_management_client_enums import PlatformType +from ._data_box_edge_management_client_enums import PosixComplianceStatus +from ._data_box_edge_management_client_enums import ResourceMoveStatus +from ._data_box_edge_management_client_enums import RoleStatus +from ._data_box_edge_management_client_enums import RoleTypes +from ._data_box_edge_management_client_enums import SSLStatus +from ._data_box_edge_management_client_enums import ShareAccessProtocol +from ._data_box_edge_management_client_enums import ShareAccessType +from ._data_box_edge_management_client_enums import ShareStatus +from ._data_box_edge_management_client_enums import ShipmentType +from ._data_box_edge_management_client_enums import SkuAvailability +from ._data_box_edge_management_client_enums import SkuName +from ._data_box_edge_management_client_enums import SkuSignupOption +from ._data_box_edge_management_client_enums import SkuTier +from ._data_box_edge_management_client_enums import SkuVersion +from ._data_box_edge_management_client_enums import StorageAccountStatus +from ._data_box_edge_management_client_enums import SubscriptionState +from ._data_box_edge_management_client_enums import TimeGrain +from ._data_box_edge_management_client_enums import TriggerEventType +from ._data_box_edge_management_client_enums import UpdateOperation +from ._data_box_edge_management_client_enums import UpdateOperationStage +from ._data_box_edge_management_client_enums import UserType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ARMBaseModel', - 'Addon', - 'AddonList', - 'Address', - 'Alert', - 'AlertErrorDetails', - 'AlertList', - 'ArcAddon', - 'AsymmetricEncryptedSecret', - 'Authentication', - 'AzureContainerInfo', - 'BandwidthSchedule', - 'BandwidthSchedulesList', - 'ClientAccessRight', - 'CloudEdgeManagementRole', - 'CloudErrorBody', - 'CniConfig', - 'ComputeResource', - 'ContactDetails', - 'Container', - 'ContainerList', - 'DCAccessCode', - 'DataBoxEdgeDevice', - 'DataBoxEdgeDeviceExtendedInfo', - 'DataBoxEdgeDeviceExtendedInfoPatch', - 'DataBoxEdgeDeviceList', - 'DataBoxEdgeDevicePatch', - 'DataBoxEdgeMoveRequest', - 'DataBoxEdgeSku', - 'DataBoxEdgeSkuList', - 'EdgeProfile', - 'EdgeProfilePatch', - 'EdgeProfileSubscription', - 'EdgeProfileSubscriptionPatch', - 'EtcdInfo', - 'FileEventTrigger', - 'FileSourceInfo', - 'GenerateCertResponse', - 'ImageRepositoryCredential', - 'IoTAddon', - 'IoTDeviceInfo', - 'IoTEdgeAgentInfo', - 'IoTRole', - 'Ipv4Config', - 'Ipv6Config', - 'Job', - 'JobErrorDetails', - 'JobErrorItem', - 'KubernetesClusterInfo', - 'KubernetesIPConfiguration', - 'KubernetesRole', - 'KubernetesRoleCompute', - 'KubernetesRoleNetwork', - 'KubernetesRoleResources', - 'KubernetesRoleStorage', - 'KubernetesRoleStorageClassInfo', - 'LoadBalancerConfig', - 'MECRole', - 'MetricConfiguration', - 'MetricCounter', - 'MetricCounterSet', - 'MetricDimension', - 'MetricDimensionV1', - 'MetricSpecificationV1', - 'MonitoringMetricConfiguration', - 'MonitoringMetricConfigurationList', - 'MountPointMap', - 'NetworkAdapter', - 'NetworkAdapterPosition', - 'NetworkSettings', - 'Node', - 'NodeInfo', - 'NodeList', - 'Operation', - 'OperationDisplay', - 'OperationsList', - 'Order', - 'OrderList', - 'OrderStatus', - 'PeriodicTimerEventTrigger', - 'PeriodicTimerSourceInfo', - 'RefreshDetails', - 'ResourceIdentity', - 'ResourceMoveDetails', - 'ResourceTypeSku', - 'Role', - 'RoleList', - 'RoleSinkInfo', - 'SecuritySettings', - 'ServiceSpecification', - 'Share', - 'ShareAccessRight', - 'ShareList', - 'Sku', - 'SkuCost', - 'SkuInformation', - 'SkuInformationList', - 'SkuLocationInfo', - 'StorageAccount', - 'StorageAccountCredential', - 'StorageAccountCredentialList', - 'StorageAccountList', - 'SubscriptionRegisteredFeatures', - 'SymmetricKey', - 'SystemData', - 'TrackingInfo', - 'Trigger', - 'TriggerList', - 'UpdateDownloadProgress', - 'UpdateInstallProgress', - 'UpdateSummary', - 'UploadCertificateRequest', - 'UploadCertificateResponse', - 'User', - 'UserAccessRight', - 'UserList', - 'AccountType', - 'AddonState', - 'AddonType', - 'AlertSeverity', - 'AuthenticationType', - 'AzureContainerDataFormat', - 'ClientPermissionType', - 'ContainerStatus', - 'CreatedByType', - 'DataBoxEdgeDeviceKind', - 'DataBoxEdgeDeviceStatus', - 'DataPolicy', - 'DayOfWeek', - 'DeviceType', - 'DownloadPhase', - 'EncryptionAlgorithm', - 'HostPlatformType', - 'InstallRebootBehavior', - 'JobStatus', - 'JobType', - 'KubernetesNodeType', - 'KubernetesState', - 'MetricAggregationType', - 'MetricCategory', - 'MetricUnit', - 'MonitoringStatus', - 'MountType', - 'MsiIdentityType', - 'NetworkAdapterDHCPStatus', - 'NetworkAdapterRDMAStatus', - 'NetworkAdapterStatus', - 'NetworkGroup', - 'NodeStatus', - 'OrderState', - 'PlatformType', - 'PosixComplianceStatus', - 'ResourceMoveStatus', - 'RoleStatus', - 'RoleTypes', - 'SSLStatus', - 'ShareAccessProtocol', - 'ShareAccessType', - 'ShareStatus', - 'ShipmentType', - 'SkuAvailability', - 'SkuName', - 'SkuSignupOption', - 'SkuTier', - 'SkuVersion', - 'StorageAccountStatus', - 'SubscriptionState', - 'TimeGrain', - 'TriggerEventType', - 'UpdateOperation', - 'UpdateOperationStage', - 'UserType', + "ARMBaseModel", + "Addon", + "AddonList", + "Address", + "Alert", + "AlertErrorDetails", + "AlertList", + "ArcAddon", + "AsymmetricEncryptedSecret", + "Authentication", + "AzureContainerInfo", + "BandwidthSchedule", + "BandwidthSchedulesList", + "ClientAccessRight", + "CloudEdgeManagementRole", + "CloudErrorBody", + "CniConfig", + "ComputeResource", + "ContactDetails", + "Container", + "ContainerList", + "DCAccessCode", + "DataBoxEdgeDevice", + "DataBoxEdgeDeviceExtendedInfo", + "DataBoxEdgeDeviceExtendedInfoPatch", + "DataBoxEdgeDeviceList", + "DataBoxEdgeDevicePatch", + "DataBoxEdgeMoveRequest", + "DataBoxEdgeSku", + "DataBoxEdgeSkuList", + "EdgeProfile", + "EdgeProfilePatch", + "EdgeProfileSubscription", + "EdgeProfileSubscriptionPatch", + "EtcdInfo", + "FileEventTrigger", + "FileSourceInfo", + "GenerateCertResponse", + "ImageRepositoryCredential", + "IoTAddon", + "IoTDeviceInfo", + "IoTEdgeAgentInfo", + "IoTRole", + "Ipv4Config", + "Ipv6Config", + "Job", + "JobErrorDetails", + "JobErrorItem", + "KubernetesClusterInfo", + "KubernetesIPConfiguration", + "KubernetesRole", + "KubernetesRoleCompute", + "KubernetesRoleNetwork", + "KubernetesRoleResources", + "KubernetesRoleStorage", + "KubernetesRoleStorageClassInfo", + "LoadBalancerConfig", + "MECRole", + "MetricConfiguration", + "MetricCounter", + "MetricCounterSet", + "MetricDimension", + "MetricDimensionV1", + "MetricSpecificationV1", + "MonitoringMetricConfiguration", + "MonitoringMetricConfigurationList", + "MountPointMap", + "NetworkAdapter", + "NetworkAdapterPosition", + "NetworkSettings", + "Node", + "NodeInfo", + "NodeList", + "Operation", + "OperationDisplay", + "OperationsList", + "Order", + "OrderList", + "OrderStatus", + "PeriodicTimerEventTrigger", + "PeriodicTimerSourceInfo", + "RefreshDetails", + "ResourceIdentity", + "ResourceMoveDetails", + "ResourceTypeSku", + "Role", + "RoleList", + "RoleSinkInfo", + "SecuritySettings", + "ServiceSpecification", + "Share", + "ShareAccessRight", + "ShareList", + "Sku", + "SkuCost", + "SkuInformation", + "SkuInformationList", + "SkuLocationInfo", + "StorageAccount", + "StorageAccountCredential", + "StorageAccountCredentialList", + "StorageAccountList", + "SubscriptionRegisteredFeatures", + "SymmetricKey", + "SystemData", + "TrackingInfo", + "Trigger", + "TriggerList", + "UpdateDownloadProgress", + "UpdateInstallProgress", + "UpdateSummary", + "UploadCertificateRequest", + "UploadCertificateResponse", + "User", + "UserAccessRight", + "UserList", + "AccountType", + "AddonState", + "AddonType", + "AlertSeverity", + "AuthenticationType", + "AzureContainerDataFormat", + "ClientPermissionType", + "ContainerStatus", + "CreatedByType", + "DataBoxEdgeDeviceKind", + "DataBoxEdgeDeviceStatus", + "DataPolicy", + "DayOfWeek", + "DeviceType", + "DownloadPhase", + "EncryptionAlgorithm", + "HostPlatformType", + "InstallRebootBehavior", + "JobStatus", + "JobType", + "KubernetesNodeType", + "KubernetesState", + "MetricAggregationType", + "MetricCategory", + "MetricUnit", + "MonitoringStatus", + "MountType", + "MsiIdentityType", + "NetworkAdapterDHCPStatus", + "NetworkAdapterRDMAStatus", + "NetworkAdapterStatus", + "NetworkGroup", + "NodeStatus", + "OrderState", + "PlatformType", + "PosixComplianceStatus", + "ResourceMoveStatus", + "RoleStatus", + "RoleTypes", + "SSLStatus", + "ShareAccessProtocol", + "ShareAccessType", + "ShareStatus", + "ShipmentType", + "SkuAvailability", + "SkuName", + "SkuSignupOption", + "SkuTier", + "SkuVersion", + "StorageAccountStatus", + "SubscriptionState", + "TimeGrain", + "TriggerEventType", + "UpdateOperation", + "UpdateOperationStage", + "UserType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_data_box_edge_management_client_enums.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_data_box_edge_management_client_enums.py index 0cec6392e961..8929fe116d25 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_data_box_edge_management_client_enums.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_data_box_edge_management_client_enums.py @@ -6,36 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of storage accessed on the storage account. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of storage accessed on the storage account.""" GENERAL_PURPOSE_STORAGE = "GeneralPurposeStorage" BLOB_STORAGE = "BlobStorage" -class AddonState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Addon Provisioning State - """ + +class AddonState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon Provisioning State.""" INVALID = "Invalid" CREATING = "Creating" @@ -45,47 +28,47 @@ class AddonState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETING = "Deleting" -class AddonType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Addon type. - """ + +class AddonType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon type.""" IOT_EDGE = "IotEdge" ARC_FOR_KUBERNETES = "ArcForKubernetes" -class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the alert. - """ + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert.""" INFORMATIONAL = "Informational" WARNING = "Warning" CRITICAL = "Critical" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The authentication type. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication type.""" INVALID = "Invalid" AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" -class AzureContainerDataFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Storage format used for the file represented by the share. - """ + +class AzureContainerDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage format used for the file represented by the share.""" BLOCK_BLOB = "BlockBlob" PAGE_BLOB = "PageBlob" AZURE_FILE = "AzureFile" -class ClientPermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed for the client. - """ + +class ClientPermissionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed for the client.""" NO_ACCESS = "NoAccess" READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the container. - """ + +class ContainerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the container.""" OK = "OK" OFFLINE = "Offline" @@ -93,27 +76,27 @@ class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DataBoxEdgeDeviceKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The etag for the devices. - """ + +class DataBoxEdgeDeviceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The etag for the devices.""" AZURE_DATA_BOX_GATEWAY = "AzureDataBoxGateway" AZURE_STACK_EDGE = "AzureStackEdge" AZURE_STACK_HUB = "AzureStackHub" AZURE_MODULAR_DATA_CENTRE = "AzureModularDataCentre" -class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the Data Box Edge/Gateway device. - """ + +class DataBoxEdgeDeviceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the Data Box Edge/Gateway device.""" READY_TO_SETUP = "ReadyToSetup" ONLINE = "Online" @@ -123,14 +106,16 @@ class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum PARTIALLY_DISCONNECTED = "PartiallyDisconnected" MAINTENANCE = "Maintenance" -class DataPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Data policy of the share. - """ + +class DataPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data policy of the share.""" CLOUD = "Cloud" LOCAL = "Local" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -140,47 +125,47 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DeviceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the Data Box Edge/Gateway device. - """ + +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the Data Box Edge/Gateway device.""" DATA_BOX_EDGE_DEVICE = "DataBoxEdgeDevice" -class DownloadPhase(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The download phase. - """ + +class DownloadPhase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The download phase.""" UNKNOWN = "Unknown" INITIALIZING = "Initializing" DOWNLOADING = "Downloading" VERIFYING = "Verifying" -class EncryptionAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The algorithm used to encrypt "Value". - """ + +class EncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The algorithm used to encrypt "Value".""" NONE = "None" AES256 = "AES256" RSAES_PKCS1_V1_5 = "RSAES_PKCS1_v_1_5" -class HostPlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Platform where the runtime is hosted. - """ + +class HostPlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Platform where the runtime is hosted.""" KUBERNETES_CLUSTER = "KubernetesCluster" LINUX_VM = "LinuxVM" -class InstallRebootBehavior(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if updates are available and at least one of the updates needs a reboot. - """ + +class InstallRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if updates are available and at least one of the updates needs a reboot.""" NEVER_REBOOTS = "NeverReboots" REQUIRES_REBOOT = "RequiresReboot" REQUEST_REBOOT = "RequestReboot" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the job.""" INVALID = "Invalid" RUNNING = "Running" @@ -190,9 +175,9 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PAUSED = "Paused" SCHEDULED = "Scheduled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" INVALID = "Invalid" SCAN_FOR_UPDATES = "ScanForUpdates" @@ -204,17 +189,17 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESTORE = "Restore" TRIGGER_SUPPORT_PACKAGE = "TriggerSupportPackage" -class KubernetesNodeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Node type - Master/Worker - """ + +class KubernetesNodeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Node type - Master/Worker.""" INVALID = "Invalid" MASTER = "Master" WORKER = "Worker" -class KubernetesState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """State of Kubernetes deployment - """ + +class KubernetesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of Kubernetes deployment.""" INVALID = "Invalid" CREATING = "Creating" @@ -224,9 +209,9 @@ class KubernetesState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETING = "Deleting" -class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric aggregation type. - """ + +class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric aggregation type.""" NOT_SPECIFIED = "NotSpecified" NONE = "None" @@ -236,16 +221,16 @@ class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) TOTAL = "Total" COUNT = "Count" -class MetricCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric category. - """ + +class MetricCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric category.""" CAPACITY = "Capacity" TRANSACTION = "Transaction" -class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric units. - """ + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric units.""" NOT_SPECIFIED = "NotSpecified" PERCENT = "Percent" @@ -256,60 +241,60 @@ class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BYTES_PER_SECOND = "BytesPerSecond" COUNT_PER_SECOND = "CountPerSecond" -class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current monitoring status of the share. - """ + +class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current monitoring status of the share.""" ENABLED = "Enabled" DISABLED = "Disabled" -class MountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Mounting type. - """ + +class MountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Mounting type.""" VOLUME = "Volume" HOST_PATH = "HostPath" -class MsiIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Identity type - """ + +class MsiIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" -class NetworkAdapterDHCPStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter has DHCP enabled. - """ + +class NetworkAdapterDHCPStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter has DHCP enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" -class NetworkAdapterRDMAStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is RDMA capable. - """ + +class NetworkAdapterRDMAStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is RDMA capable.""" INCAPABLE = "Incapable" CAPABLE = "Capable" -class NetworkAdapterStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is valid. - """ + +class NetworkAdapterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is valid.""" INACTIVE = "Inactive" ACTIVE = "Active" -class NetworkGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The network group. - """ + +class NetworkGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network group.""" NONE = "None" NON_RDMA = "NonRDMA" RDMA = "RDMA" -class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the individual node - """ + +class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the individual node.""" UNKNOWN = "Unknown" UP = "Up" @@ -317,9 +302,9 @@ class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REBOOTING = "Rebooting" SHUTTING_DOWN = "ShuttingDown" -class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the order as per the allowed status types. - """ + +class OrderState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the order as per the allowed status types.""" UNTRACKED = "Untracked" AWAITING_FULFILMENT = "AwaitingFulfilment" @@ -339,37 +324,39 @@ class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PICKUP_COMPLETED = "PickupCompleted" AWAITING_DROP = "AwaitingDrop" -class PlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Host OS supported by the Arc addon. - """ + +class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host OS supported by the Arc addon.""" WINDOWS = "Windows" LINUX = "Linux" -class PosixComplianceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """If provisioned storage is posix compliant. - """ + +class PosixComplianceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """If provisioned storage is posix compliant.""" INVALID = "Invalid" ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceMoveStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Denotes whether move operation is in progress - """ + +class ResourceMoveStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Denotes whether move operation is in progress.""" NONE = "None" RESOURCE_MOVE_IN_PROGRESS = "ResourceMoveInProgress" RESOURCE_MOVE_FAILED = "ResourceMoveFailed" -class RoleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Local Edge Management Status - """ + +class RoleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Local Edge Management Status.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RoleTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleTypes.""" IOT = "IOT" ASA = "ASA" @@ -379,24 +366,24 @@ class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CLOUD_EDGE_MANAGEMENT = "CloudEdgeManagement" KUBERNETES = "Kubernetes" -class ShareAccessProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Access protocol to be used by the share. - """ + +class ShareAccessProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access protocol to be used by the share.""" SMB = "SMB" NFS = "NFS" -class ShareAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed on the share for this user. - """ + +class ShareAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed on the share for this user.""" CHANGE = "Change" READ = "Read" CUSTOM = "Custom" -class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the share. - """ + +class ShareStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the share.""" OFFLINE = "Offline" UNKNOWN = "Unknown" @@ -404,22 +391,24 @@ class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class ShipmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class ShipmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ShipmentType.""" NOT_APPLICABLE = "NotApplicable" SHIPPED_TO_CUSTOMER = "ShippedToCustomer" SELF_PICKUP = "SelfPickup" -class SkuAvailability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Links to the next set of results - """ + +class SkuAvailability(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Links to the next set of results.""" AVAILABLE = "Available" UNAVAILABLE = "Unavailable" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku name. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku name.""" GATEWAY = "Gateway" EDGE = "Edge" @@ -443,36 +432,36 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RCA_LARGE = "RCA_Large" RDC = "RDC" -class SkuSignupOption(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Sku can be signed up by customer or not. - """ + +class SkuSignupOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sku can be signed up by customer or not.""" NONE = "None" AVAILABLE = "Available" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku tier. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku tier.""" STANDARD = "Standard" -class SkuVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Availability of the Sku as preview/stable. - """ + +class SkuVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Availability of the Sku as preview/stable.""" STABLE = "Stable" PREVIEW = "Preview" -class SSLStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Signifies whether SSL needs to be enabled or not. - """ + +class SSLStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Signifies whether SSL needs to be enabled or not.""" ENABLED = "Enabled" DISABLED = "Disabled" -class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the storage account - """ + +class StorageAccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the storage account.""" OK = "OK" OFFLINE = "Offline" @@ -480,7 +469,9 @@ class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SubscriptionState.""" REGISTERED = "Registered" WARNED = "Warned" @@ -488,7 +479,9 @@ class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETED = "Deleted" UNREGISTERED = "Unregistered" -class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class TimeGrain(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TimeGrain.""" PT1_M = "PT1M" PT5_M = "PT5M" @@ -499,25 +492,25 @@ class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PT12_H = "PT12H" PT1_D = "PT1D" -class TriggerEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Trigger Kind. - """ + +class TriggerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trigger Kind.""" FILE_EVENT = "FileEvent" PERIODIC_TIMER_EVENT = "PeriodicTimerEvent" -class UpdateOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current update operation. - """ + +class UpdateOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current update operation.""" NONE = "None" SCAN = "Scan" DOWNLOAD = "Download" INSTALL = "Install" -class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current stage of the update operation. - """ + +class UpdateOperationStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current stage of the update operation.""" UNKNOWN = "Unknown" INITIAL = "Initial" @@ -537,9 +530,9 @@ class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESCAN_COMPLETE = "RescanComplete" RESCAN_FAILED = "RescanFailed" -class UserType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of the user. - """ + +class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the user.""" SHARE = "Share" LOCAL_MANAGEMENT = "LocalManagement" diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_models.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_models.py deleted file mode 100644 index b67bee38c64f..000000000000 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_models.py +++ /dev/null @@ -1,4986 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class ARMBaseModel(msrest.serialization.Model): - """Represents the base class for all object models. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Addon(ARMBaseModel): - """Role Addon. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ArcAddon, IoTAddon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - _subtype_map = { - 'kind': {'ArcForKubernetes': 'ArcAddon', 'IotEdge': 'IoTAddon'} - } - - def __init__( - self, - **kwargs - ): - super(Addon, self).__init__(**kwargs) - self.kind = 'Addon' # type: str - self.system_data = None - - -class AddonList(msrest.serialization.Model): - """Collection of all the Role addon on the Azure Stack Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Addon] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Address(msrest.serialization.Model): - """The shipping address of the customer. - - All required parameters must be populated in order to send to Azure. - - :param address_line1: The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: The postal code. - :type postal_code: str - :param city: The city name. - :type city: str - :param state: The state name. - :type state: str - :param country: Required. The country name. - :type country: str - """ - - _validation = { - 'country': {'required': True}, - } - - _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Address, self).__init__(**kwargs) - self.address_line1 = kwargs.get('address_line1', None) - self.address_line2 = kwargs.get('address_line2', None) - self.address_line3 = kwargs.get('address_line3', None) - self.postal_code = kwargs.get('postal_code', None) - self.city = kwargs.get('city', None) - self.state = kwargs.get('state', None) - self.country = kwargs['country'] - - -class Alert(ARMBaseModel): - """Alert on the data box edge/gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Alert generated in the resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :ivar title: Alert title. - :vartype title: str - :ivar alert_type: Alert type. - :vartype alert_type: str - :ivar appeared_at_date_time: UTC time when the alert appeared. - :vartype appeared_at_date_time: ~datetime.datetime - :ivar recommendation: Alert recommendation. - :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", - "Critical". - :vartype severity: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AlertSeverity - :ivar error_details: Error details of the alert. - :vartype error_details: ~azure.mgmt.databoxedge.v2020_09_01.models.AlertErrorDetails - :ivar detailed_information: Alert details. - :vartype detailed_information: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) - self.system_data = None - self.title = None - self.alert_type = None - self.appeared_at_date_time = None - self.recommendation = None - self.severity = None - self.error_details = None - self.detailed_information = None - - -class AlertErrorDetails(msrest.serialization.Model): - """Error details for the alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code. - :vartype error_code: str - :ivar error_message: Error Message. - :vartype error_message: str - :ivar occurrences: Number of occurrences. - :vartype occurrences: int - """ - - _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) - self.error_code = None - self.error_message = None - self.occurrences = None - - -class AlertList(msrest.serialization.Model): - """Collection of alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Alert] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ArcAddon(Addon): - """Arc Addon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param subscription_id: Required. Arc resource subscription Id. - :type subscription_id: str - :param resource_group_name: Required. Arc resource group name. - :type resource_group_name: str - :param resource_name: Required. Arc resource Name. - :type resource_name: str - :param resource_location: Required. Arc resource location. - :type resource_location: str - :ivar version: Arc resource version. - :vartype version: str - :ivar host_platform: Host OS supported by the Arc addon. Possible values include: "Windows", - "Linux". - :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'subscription_id': {'required': True}, - 'resource_group_name': {'required': True}, - 'resource_name': {'required': True}, - 'resource_location': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'properties.resourceGroupName', 'type': 'str'}, - 'resource_name': {'key': 'properties.resourceName', 'type': 'str'}, - 'resource_location': {'key': 'properties.resourceLocation', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArcAddon, self).__init__(**kwargs) - self.kind = 'ArcForKubernetes' # type: str - self.subscription_id = kwargs['subscription_id'] - self.resource_group_name = kwargs['resource_group_name'] - self.resource_name = kwargs['resource_name'] - self.resource_location = kwargs['resource_location'] - self.version = None - self.host_platform = None - self.host_platform_type = None - self.provisioning_state = None - - -class AsymmetricEncryptedSecret(msrest.serialization.Model): - """Represent the secrets intended for encryption with asymmetric key pair. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the - value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or - ~azure.mgmt.databoxedge.v2020_09_01.models.EncryptionAlgorithm - """ - - _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) - self.value = kwargs['value'] - self.encryption_cert_thumbprint = kwargs.get('encryption_cert_thumbprint', None) - self.encryption_algorithm = kwargs['encryption_algorithm'] - - -class Authentication(msrest.serialization.Model): - """Authentication mechanism for IoT devices. - - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2020_09_01.models.SymmetricKey - """ - - _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, - } - - def __init__( - self, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) - self.symmetric_key = kwargs.get('symmetric_key', None) - - -class AzureContainerInfo(msrest.serialization.Model): - """Azure container mapping of the endpoint. - - All required parameters must be populated in order to send to Azure. - - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerDataFormat - """ - - _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, - } - - _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) - self.storage_account_credential_id = kwargs['storage_account_credential_id'] - self.container_name = kwargs['container_name'] - self.data_format = kwargs['data_format'] - - -class BandwidthSchedule(ARMBaseModel): - """The bandwidth schedule details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Bandwidth object related to ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2020_09_01.models.DayOfWeek] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) - self.system_data = None - self.start = kwargs['start'] - self.stop = kwargs['stop'] - self.rate_in_mbps = kwargs['rate_in_mbps'] - self.days = kwargs['days'] - - -class BandwidthSchedulesList(msrest.serialization.Model): - """The collection of bandwidth schedules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of bandwidth schedules. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ClientAccessRight(msrest.serialization.Model): - """The mapping between a particular client IP and the type of access client has on the NFS share. - - All required parameters must be populated in order to send to Azure. - - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ClientPermissionType - """ - - _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, - } - - _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) - self.client = kwargs['client'] - self.access_permission = kwargs['access_permission'] - - -class Role(ARMBaseModel): - """Compute role. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - _subtype_map = { - 'kind': {'CloudEdgeManagement': 'CloudEdgeManagementRole', 'IOT': 'IoTRole', 'Kubernetes': 'KubernetesRole', 'MEC': 'MECRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str - self.system_data = None - - -class CloudEdgeManagementRole(Role): - """CloudEdgeManagementRole role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :ivar local_management_status: Local Edge Management Status. Possible values include: - "Enabled", "Disabled". - :vartype local_management_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus - :ivar edge_profile: Edge Profile of the resource. - :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfile - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'local_management_status': {'readonly': True}, - 'edge_profile': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'local_management_status': {'key': 'properties.localManagementStatus', 'type': 'str'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudEdgeManagementRole, self).__init__(**kwargs) - self.kind = 'CloudEdgeManagement' # type: str - self.local_management_status = None - self.edge_profile = None - self.role_status = kwargs.get('role_status', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2020_09_01.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class CniConfig(msrest.serialization.Model): - """Cni configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Cni type. - :vartype type: str - :ivar version: Cni version. - :vartype version: str - :ivar pod_subnet: Pod Subnet. - :vartype pod_subnet: str - :ivar service_subnet: Service subnet. - :vartype service_subnet: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - 'pod_subnet': {'readonly': True}, - 'service_subnet': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'pod_subnet': {'key': 'podSubnet', 'type': 'str'}, - 'service_subnet': {'key': 'serviceSubnet', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CniConfig, self).__init__(**kwargs) - self.type = None - self.version = None - self.pod_subnet = None - self.service_subnet = None - - -class ComputeResource(msrest.serialization.Model): - """Compute infrastructure Resource. - - All required parameters must be populated in order to send to Azure. - - :param processor_count: Required. Processor count. - :type processor_count: int - :param memory_in_gb: Required. Memory in GB. - :type memory_in_gb: long - """ - - _validation = { - 'processor_count': {'required': True}, - 'memory_in_gb': {'required': True}, - } - - _attribute_map = { - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeResource, self).__init__(**kwargs) - self.processor_count = kwargs['processor_count'] - self.memory_in_gb = kwargs['memory_in_gb'] - - -class ContactDetails(msrest.serialization.Model): - """Contains all the contact details of the customer. - - All required parameters must be populated in order to send to Azure. - - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] - """ - - _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) - self.contact_person = kwargs['contact_person'] - self.company_name = kwargs['company_name'] - self.phone = kwargs['phone'] - self.email_list = kwargs['email_list'] - - -class Container(ARMBaseModel): - """Represents a container on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Container in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". - :vartype container_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerDataFormat - :ivar refresh_details: Details of the refresh job on this container. - :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_09_01.models.RefreshDetails - :ivar created_date_time: The UTC time when container got created. - :vartype created_date_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Container, self).__init__(**kwargs) - self.system_data = None - self.container_status = None - self.data_format = kwargs['data_format'] - self.refresh_details = None - self.created_date_time = None - - -class ContainerList(msrest.serialization.Model): - """Collection of all the containers on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of containers. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Container] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevice(ARMBaseModel): - """The Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure - geographical region (for example, West US, East US, or Southeast Asia). The geographical region - of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2020_09_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceIdentity - :ivar kind: The etag for the devices. Possible values include: "AzureDataBoxGateway", - "AzureStackEdge", "AzureStackHub", "AzureModularDataCentre". - :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceKind - :ivar system_data: DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or - ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceStatus - :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. - :vartype serial_number: str - :ivar description: The Description of the Data Box Edge/Gateway device. - :vartype description: str - :ivar model_description: The description of the Data Box Edge/Gateway device model. - :vartype model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". - :vartype device_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DeviceType - :ivar friendly_name: The Data Box Edge/Gateway device name. - :vartype friendly_name: str - :ivar culture: The Data Box Edge/Gateway device culture. - :vartype culture: str - :ivar device_model: The Data Box Edge/Gateway device model. - :vartype device_model: str - :ivar device_software_version: The Data Box Edge/Gateway device software version. - :vartype device_software_version: str - :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long - :ivar time_zone: The Data Box Edge/Gateway device timezone. - :vartype time_zone: str - :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). - :vartype device_hcs_version: str - :ivar configured_role_types: Type of compute roles configured. - :vartype configured_role_types: list[str or - ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes] - :ivar node_count: The number of nodes in the cluster. - :vartype node_count: int - :ivar resource_move_details: The details of the move operation on this resource. - :vartype resource_move_details: ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceMoveDetails - :ivar edge_profile: The details of Edge Profile for this resource. - :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfile - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'system_data': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'description': {'readonly': True}, - 'model_description': {'readonly': True}, - 'device_type': {'readonly': True}, - 'friendly_name': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'edge_profile': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - 'resource_move_details': {'key': 'properties.resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - self.etag = kwargs.get('etag', None) - self.identity = kwargs.get('identity', None) - self.kind = None - self.system_data = None - self.data_box_edge_device_status = kwargs.get('data_box_edge_device_status', None) - self.serial_number = None - self.description = None - self.model_description = None - self.device_type = None - self.friendly_name = None - self.culture = None - self.device_model = None - self.device_software_version = None - self.device_local_capacity = None - self.time_zone = None - self.device_hcs_version = None - self.configured_role_types = None - self.node_count = None - self.resource_move_details = None - self.edge_profile = None - - -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): - """The extended Info of the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to - encrypt any secret. - :type encryption_key: str - :ivar resource_key: The Resource ID of the Resource. - :vartype resource_key: str - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key - Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client - Key Vault. - :type channel_integrity_key_version: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - 'client_secret_store_id': {'key': 'properties.clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'properties.clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'properties.channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'properties.channelIntegrityKeyVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) - self.encryption_key_thumbprint = kwargs.get('encryption_key_thumbprint', None) - self.encryption_key = kwargs.get('encryption_key', None) - self.resource_key = None - self.client_secret_store_id = kwargs.get('client_secret_store_id', None) - self.client_secret_store_url = kwargs.get('client_secret_store_url', None) - self.channel_integrity_key_name = kwargs.get('channel_integrity_key_name', None) - self.channel_integrity_key_version = kwargs.get('channel_integrity_key_version', None) - - -class DataBoxEdgeDeviceExtendedInfoPatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device extended info patch. - - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key - Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client - Key Vault. - :type channel_integrity_key_version: str - """ - - _attribute_map = { - 'client_secret_store_id': {'key': 'clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'channelIntegrityKeyVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfoPatch, self).__init__(**kwargs) - self.client_secret_store_id = kwargs.get('client_secret_store_id', None) - self.client_secret_store_url = kwargs.get('client_secret_store_url', None) - self.channel_integrity_key_name = kwargs.get('channel_integrity_key_name', None) - self.channel_integrity_key_version = kwargs.get('channel_integrity_key_version', None) - - -class DataBoxEdgeDeviceList(msrest.serialization.Model): - """The collection of Data Box Edge/Gateway devices. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Data Box Edge/Gateway devices. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevicePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device patch. - - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceIdentity - :param edge_profile: Edge Profile property of the Data Box Edge/Gateway device. - :type edge_profile: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfilePatch - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfilePatch'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.identity = kwargs.get('identity', None) - self.edge_profile = kwargs.get('edge_profile', None) - - -class DataBoxEdgeMoveRequest(msrest.serialization.Model): - """Resource Move details. - - All required parameters must be populated in order to send to Azure. - - :param target_resource_group: Required. Target resource group ARMId. - :type target_resource_group: str - :param resources: Required. List of resources to be moved. - :type resources: list[str] - """ - - _validation = { - 'target_resource_group': {'required': True}, - 'resources': {'required': True}, - } - - _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeMoveRequest, self).__init__(**kwargs) - self.target_resource_group = kwargs['target_resource_group'] - self.resources = kwargs['resources'] - - -class DataBoxEdgeSku(msrest.serialization.Model): - """The Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". - :vartype name: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuName - :ivar kind: The Sku kind. - :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". - :vartype tier: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuTier - :ivar size: The Sku kind. - :vartype size: str - :ivar family: The Sku family. - :vartype family: str - :ivar locations: Availability of the Sku for the region. - :vartype locations: list[str] - :ivar api_versions: The API versions in which Sku is available. - :vartype api_versions: list[str] - :ivar location_info: Availability of the Sku for the location/zone/site. - :vartype location_info: list[~azure.mgmt.databoxedge.v2020_09_01.models.SkuLocationInfo] - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2020_09_01.models.SkuCost] - :ivar signup_option: Sku can be signed up by customer or not. Possible values include: "None", - "Available". - :vartype signup_option: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuSignupOption - :ivar version: Availability of the Sku as preview/stable. Possible values include: "Stable", - "Preview". - :vartype version: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuVersion - :ivar availability: Links to the next set of results. Possible values include: "Available", - "Unavailable". - :vartype availability: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuAvailability - :ivar shipment_types: List of Shipment Types supported by this SKU. - :vartype shipment_types: list[str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShipmentType] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - 'shipment_types': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, - 'shipment_types': {'key': 'shipmentTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) - self.resource_type = None - self.name = None - self.kind = None - self.tier = None - self.size = None - self.family = None - self.locations = None - self.api_versions = None - self.location_info = None - self.costs = None - self.signup_option = None - self.version = None - self.availability = None - self.shipment_types = None - - -class DataBoxEdgeSkuList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceType Sku. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DCAccessCode(msrest.serialization.Model): - """DC Access code in the case of Self Managed Shipping. - - :param auth_code: DCAccess Code for the Self Managed shipment. - :type auth_code: str - """ - - _attribute_map = { - 'auth_code': {'key': 'properties.authCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DCAccessCode, self).__init__(**kwargs) - self.auth_code = kwargs.get('auth_code', None) - - -class EdgeProfile(msrest.serialization.Model): - """Details about Edge Profile for the resource. - - :param subscription: Edge Profile Subscription. - :type subscription: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfileSubscription - """ - - _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscription'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfile, self).__init__(**kwargs) - self.subscription = kwargs.get('subscription', None) - - -class EdgeProfilePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway Edge Profile patch. - - :param subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. - :type subscription: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfileSubscriptionPatch - """ - - _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscriptionPatch'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfilePatch, self).__init__(**kwargs) - self.subscription = kwargs.get('subscription', None) - - -class EdgeProfileSubscription(msrest.serialization.Model): - """Subscription details for the Edge Profile. - - :param registration_id: Edge Subscription Registration ID. - :type registration_id: str - :param id: ARM ID of the subscription. - :type id: str - :param state: Possible values include: "Registered", "Warned", "Suspended", "Deleted", - "Unregistered". - :type state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SubscriptionState - :param registration_date: - :type registration_date: str - :param subscription_id: - :type subscription_id: str - :param tenant_id: - :type tenant_id: str - :param location_placement_id: - :type location_placement_id: str - :param quota_id: - :type quota_id: str - :param serialized_details: - :type serialized_details: str - :param registered_features: - :type registered_features: - list[~azure.mgmt.databoxedge.v2020_09_01.models.SubscriptionRegisteredFeatures] - """ - - _attribute_map = { - 'registration_id': {'key': 'registrationId', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'registration_date': {'key': 'registrationDate', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'location_placement_id': {'key': 'properties.locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'properties.quotaId', 'type': 'str'}, - 'serialized_details': {'key': 'properties.serializedDetails', 'type': 'str'}, - 'registered_features': {'key': 'properties.registeredFeatures', 'type': '[SubscriptionRegisteredFeatures]'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfileSubscription, self).__init__(**kwargs) - self.registration_id = kwargs.get('registration_id', None) - self.id = kwargs.get('id', None) - self.state = kwargs.get('state', None) - self.registration_date = kwargs.get('registration_date', None) - self.subscription_id = kwargs.get('subscription_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.location_placement_id = kwargs.get('location_placement_id', None) - self.quota_id = kwargs.get('quota_id', None) - self.serialized_details = kwargs.get('serialized_details', None) - self.registered_features = kwargs.get('registered_features', None) - - -class EdgeProfileSubscriptionPatch(msrest.serialization.Model): - """The Data Box Edge/Gateway Edge Profile Subscription patch. - - :param id: The path ID that uniquely identifies the subscription of the edge profile. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfileSubscriptionPatch, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class EtcdInfo(msrest.serialization.Model): - """Etcd configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Etcd type. - :vartype type: str - :ivar version: Etcd version. - :vartype version: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EtcdInfo, self).__init__(**kwargs) - self.type = None - self.version = None - - -class Trigger(ARMBaseModel): - """Trigger details. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.TriggerEventType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } - - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.system_data = None - self.kind = 'Trigger' # type: str - - -class FileEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2020_09_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2020_09_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class FileSourceInfo(msrest.serialization.Model): - """File source details. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. File share ID. - :type share_id: str - """ - - _validation = { - 'share_id': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - - -class GenerateCertResponse(msrest.serialization.Model): - """Used in activation key generation flow. - - :param public_key: Gets or sets base64 encoded certificate raw data, - this is the public part needed to be uploaded to cert vault. - :type public_key: str - :param private_key: Gets or sets base64 encoded private part of the certificate, - needed to form the activation key. - :type private_key: str - :param expiry_time_in_utc: Gets or sets expiry time in UTC. - :type expiry_time_in_utc: str - """ - - _attribute_map = { - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'expiry_time_in_utc': {'key': 'expiryTimeInUTC', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GenerateCertResponse, self).__init__(**kwargs) - self.public_key = kwargs.get('public_key', None) - self.private_key = kwargs.get('private_key', None) - self.expiry_time_in_utc = kwargs.get('expiry_time_in_utc', None) - - -class ImageRepositoryCredential(msrest.serialization.Model): - """Image repository credential. - - All required parameters must be populated in order to send to Azure. - - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, - } - - _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageRepositoryCredential, self).__init__(**kwargs) - self.image_repository_url = kwargs['image_repository_url'] - self.user_name = kwargs['user_name'] - self.password = kwargs.get('password', None) - - -class IoTAddon(Addon): - """IoT Addon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param io_t_device_details: Required. IoT device metadata to which appliance needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo - :param io_t_edge_device_details: Required. IoT edge device to which the IoT Addon needs to be - configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo - :ivar version: Version of IoT running on the appliance. - :vartype version: str - :ivar host_platform: Host OS supported by the IoT addon. Possible values include: "Windows", - "Linux". - :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'io_t_device_details': {'required': True}, - 'io_t_edge_device_details': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTAddon, self).__init__(**kwargs) - self.kind = 'IotEdge' # type: str - self.io_t_device_details = kwargs['io_t_device_details'] - self.io_t_edge_device_details = kwargs['io_t_edge_device_details'] - self.version = None - self.host_platform = None - self.host_platform_type = None - self.provisioning_state = None - - -class IoTDeviceInfo(msrest.serialization.Model): - """Metadata of IoT device/IoT Edge device to be configured. - - All required parameters must be populated in order to send to Azure. - - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2020_09_01.models.Authentication - """ - - _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) - self.device_id = kwargs['device_id'] - self.io_t_host_hub = kwargs['io_t_host_hub'] - self.io_t_host_hub_id = kwargs.get('io_t_host_hub_id', None) - self.authentication = kwargs.get('authentication', None) - - -class IoTEdgeAgentInfo(msrest.serialization.Model): - """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. - - All required parameters must be populated in order to send to Azure. - - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: ~azure.mgmt.databoxedge.v2020_09_01.models.ImageRepositoryCredential - """ - - _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, - } - - _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) - self.image_name = kwargs['image_name'] - self.tag = kwargs['tag'] - self.image_repository = kwargs.get('image_repository', None) - - -class IoTRole(Role): - """Compute role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", - "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot - runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.HostPlatformType - :param compute_resource: Resource allocation. - :type compute_resource: ~azure.mgmt.databoxedge.v2020_09_01.models.ComputeResource - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'compute_resource': {'key': 'properties.computeResource', 'type': 'ComputeResource'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.io_t_device_details = kwargs.get('io_t_device_details', None) - self.io_t_edge_device_details = kwargs.get('io_t_edge_device_details', None) - self.share_mappings = kwargs.get('share_mappings', None) - self.io_t_edge_agent_info = kwargs.get('io_t_edge_agent_info', None) - self.host_platform_type = None - self.compute_resource = kwargs.get('compute_resource', None) - self.role_status = kwargs.get('role_status', None) - - -class Ipv4Config(msrest.serialization.Model): - """Details related to the IPv4 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv4 address of the network adapter. - :vartype ip_address: str - :ivar subnet: The IPv4 subnet of the network adapter. - :vartype subnet: str - :ivar gateway: The IPv4 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) - self.ip_address = None - self.subnet = None - self.gateway = None - - -class Ipv6Config(msrest.serialization.Model): - """Details related to the IPv6 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv6 address of the network adapter. - :vartype ip_address: str - :ivar prefix_length: The IPv6 prefix of the network adapter. - :vartype prefix_length: int - :ivar gateway: The IPv6 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) - self.ip_address = None - self.prefix_length = None - self.gateway = None - - -class Job(msrest.serialization.Model): - """A device job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The name of the object. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.JobStatus - :ivar start_time: The UTC date and time at which the job started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The UTC date and time at which the job completed. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: The percentage of the job that is complete. - :vartype percent_complete: int - :ivar error: The error details. - :vartype error: ~azure.mgmt.databoxedge.v2020_09_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer", "Backup", "Restore", - "TriggerSupportPackage". - :vartype job_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", - "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", - "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". - :vartype current_stage: str or ~azure.mgmt.databoxedge.v2020_09_01.models.UpdateOperationStage - :ivar download_progress: The download progress. - :vartype download_progress: ~azure.mgmt.databoxedge.v2020_09_01.models.UpdateDownloadProgress - :ivar install_progress: The install progress. - :vartype install_progress: ~azure.mgmt.databoxedge.v2020_09_01.models.UpdateInstallProgress - :ivar total_refresh_errors: Total number of errors encountered during the refresh process. - :vartype total_refresh_errors: int - :ivar error_manifest_file: Local share/remote container relative path to the error manifest - file of the refresh. - :vartype error_manifest_file: str - :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. - :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_time = None - self.end_time = None - self.percent_complete = None - self.error = None - self.job_type = None - self.current_stage = None - self.download_progress = None - self.install_progress = None - self.total_refresh_errors = None - self.error_manifest_file = None - self.refreshed_entity_id = None - self.folder = kwargs.get('folder', None) - - -class JobErrorDetails(msrest.serialization.Model): - """The job error information containing the list of job errors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_details: The error details. - :vartype error_details: list[~azure.mgmt.databoxedge.v2020_09_01.models.JobErrorItem] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) - self.error_details = None - self.code = None - self.message = None - - -class JobErrorItem(msrest.serialization.Model): - """The job error items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendations: The recommended actions. - :vartype recommendations: list[str] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) - self.recommendations = None - self.code = None - self.message = None - - -class KubernetesClusterInfo(msrest.serialization.Model): - """Kubernetes cluster configuration. - - 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 etcd_info: Etcd configuration. - :vartype etcd_info: ~azure.mgmt.databoxedge.v2020_09_01.models.EtcdInfo - :ivar nodes: Kubernetes cluster nodes. - :vartype nodes: list[~azure.mgmt.databoxedge.v2020_09_01.models.NodeInfo] - :param version: Required. Kubernetes cluster version. - :type version: str - """ - - _validation = { - 'etcd_info': {'readonly': True}, - 'nodes': {'readonly': True}, - 'version': {'required': True}, - } - - _attribute_map = { - 'etcd_info': {'key': 'etcdInfo', 'type': 'EtcdInfo'}, - 'nodes': {'key': 'nodes', 'type': '[NodeInfo]'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesClusterInfo, self).__init__(**kwargs) - self.etcd_info = None - self.nodes = None - self.version = kwargs['version'] - - -class KubernetesIPConfiguration(msrest.serialization.Model): - """Kubernetes node IP configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar port: Port of the Kubernetes node. - :vartype port: str - :param ip_address: IP address of the Kubernetes node. - :type ip_address: str - """ - - _validation = { - 'port': {'readonly': True}, - } - - _attribute_map = { - 'port': {'key': 'port', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesIPConfiguration, self).__init__(**kwargs) - self.port = None - self.ip_address = kwargs.get('ip_address', None) - - -class KubernetesRole(Role): - """Kubernetes role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param host_platform: Host OS supported by the Kubernetes role. Possible values include: - "Windows", "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType - :ivar provisioning_state: State of Kubernetes deployment. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesState - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.HostPlatformType - :param kubernetes_cluster_info: Kubernetes cluster configuration. - :type kubernetes_cluster_info: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesClusterInfo - :param kubernetes_role_resources: Kubernetes role resources. - :type kubernetes_role_resources: - ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleResources - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'kubernetes_cluster_info': {'key': 'properties.kubernetesClusterInfo', 'type': 'KubernetesClusterInfo'}, - 'kubernetes_role_resources': {'key': 'properties.kubernetesRoleResources', 'type': 'KubernetesRoleResources'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRole, self).__init__(**kwargs) - self.kind = 'Kubernetes' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.provisioning_state = None - self.host_platform_type = None - self.kubernetes_cluster_info = kwargs.get('kubernetes_cluster_info', None) - self.kubernetes_role_resources = kwargs.get('kubernetes_role_resources', None) - self.role_status = kwargs.get('role_status', None) - - -class KubernetesRoleCompute(msrest.serialization.Model): - """Kubernetes role compute resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param vm_profile: Required. VM profile. - :type vm_profile: str - :ivar memory_in_bytes: Memory in bytes. - :vartype memory_in_bytes: long - :ivar processor_count: Processor count. - :vartype processor_count: int - """ - - _validation = { - 'vm_profile': {'required': True}, - 'memory_in_bytes': {'readonly': True}, - 'processor_count': {'readonly': True}, - } - - _attribute_map = { - 'vm_profile': {'key': 'vmProfile', 'type': 'str'}, - 'memory_in_bytes': {'key': 'memoryInBytes', 'type': 'long'}, - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleCompute, self).__init__(**kwargs) - self.vm_profile = kwargs['vm_profile'] - self.memory_in_bytes = None - self.processor_count = None - - -class KubernetesRoleNetwork(msrest.serialization.Model): - """Kubernetes role network resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar cni_config: Cni configuration. - :vartype cni_config: ~azure.mgmt.databoxedge.v2020_09_01.models.CniConfig - :ivar load_balancer_config: Load balancer configuration. - :vartype load_balancer_config: ~azure.mgmt.databoxedge.v2020_09_01.models.LoadBalancerConfig - """ - - _validation = { - 'cni_config': {'readonly': True}, - 'load_balancer_config': {'readonly': True}, - } - - _attribute_map = { - 'cni_config': {'key': 'cniConfig', 'type': 'CniConfig'}, - 'load_balancer_config': {'key': 'loadBalancerConfig', 'type': 'LoadBalancerConfig'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleNetwork, self).__init__(**kwargs) - self.cni_config = None - self.load_balancer_config = None - - -class KubernetesRoleResources(msrest.serialization.Model): - """Kubernetes role resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param storage: Kubernetes role storage resource. - :type storage: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleStorage - :param compute: Required. Kubernetes role compute resource. - :type compute: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleCompute - :ivar network: Kubernetes role network resource. - :vartype network: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleNetwork - """ - - _validation = { - 'compute': {'required': True}, - 'network': {'readonly': True}, - } - - _attribute_map = { - 'storage': {'key': 'storage', 'type': 'KubernetesRoleStorage'}, - 'compute': {'key': 'compute', 'type': 'KubernetesRoleCompute'}, - 'network': {'key': 'network', 'type': 'KubernetesRoleNetwork'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleResources, self).__init__(**kwargs) - self.storage = kwargs.get('storage', None) - self.compute = kwargs['compute'] - self.network = None - - -class KubernetesRoleStorage(msrest.serialization.Model): - """Kubernetes role storage resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar storage_classes: Kubernetes storage class info. - :vartype storage_classes: - list[~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleStorageClassInfo] - :param endpoints: Mount points of shares in role(s). - :type endpoints: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] - """ - - _validation = { - 'storage_classes': {'readonly': True}, - } - - _attribute_map = { - 'storage_classes': {'key': 'storageClasses', 'type': '[KubernetesRoleStorageClassInfo]'}, - 'endpoints': {'key': 'endpoints', 'type': '[MountPointMap]'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorage, self).__init__(**kwargs) - self.storage_classes = None - self.endpoints = kwargs.get('endpoints', None) - - -class KubernetesRoleStorageClassInfo(msrest.serialization.Model): - """Kubernetes storage class info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Storage class name. - :vartype name: str - :ivar type: Storage class type. - :vartype type: str - :ivar posix_compliant: If provisioned storage is posix compliant. Possible values include: - "Invalid", "Enabled", "Disabled". - :vartype posix_compliant: str or - ~azure.mgmt.databoxedge.v2020_09_01.models.PosixComplianceStatus - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'posix_compliant': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'posix_compliant': {'key': 'posixCompliant', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorageClassInfo, self).__init__(**kwargs) - self.name = None - self.type = None - self.posix_compliant = None - - -class LoadBalancerConfig(msrest.serialization.Model): - """Load balancer configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Load balancer type. - :vartype type: str - :ivar version: Load balancer version. - :vartype version: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LoadBalancerConfig, self).__init__(**kwargs) - self.type = None - self.version = None - - -class MECRole(Role): - """MEC role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param connection_string: Activation key of the MEC. - :type connection_string: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'AsymmetricEncryptedSecret'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MECRole, self).__init__(**kwargs) - self.kind = 'MEC' # type: str - self.connection_string = kwargs.get('connection_string', None) - self.role_status = kwargs.get('role_status', None) - - -class MetricConfiguration(msrest.serialization.Model): - """Metric configuration. - - All required parameters must be populated in order to send to Azure. - - :param resource_id: Required. The Resource ID on which the metrics should be pushed. - :type resource_id: str - :param mdm_account: The MDM account to which the counters should be pushed. - :type mdm_account: str - :param metric_name_space: The MDM namespace to which the counters should be pushed. This is - required if MDMAccount is specified. - :type metric_name_space: str - :param counter_sets: Required. Host name for the IoT hub associated to the device. - :type counter_sets: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricCounterSet] - """ - - _validation = { - 'resource_id': {'required': True}, - 'counter_sets': {'required': True}, - } - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'mdm_account': {'key': 'mdmAccount', 'type': 'str'}, - 'metric_name_space': {'key': 'metricNameSpace', 'type': 'str'}, - 'counter_sets': {'key': 'counterSets', 'type': '[MetricCounterSet]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricConfiguration, self).__init__(**kwargs) - self.resource_id = kwargs['resource_id'] - self.mdm_account = kwargs.get('mdm_account', None) - self.metric_name_space = kwargs.get('metric_name_space', None) - self.counter_sets = kwargs['counter_sets'] - - -class MetricCounter(msrest.serialization.Model): - """The metric counter. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The counter name. - :type name: str - :param instance: The instance from which counter should be collected. - :type instance: str - :param dimension_filter: The dimension filter. - :type dimension_filter: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimension] - :param additional_dimensions: The additional dimensions to be added to metric. - :type additional_dimensions: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimension] - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, - 'dimension_filter': {'key': 'dimensionFilter', 'type': '[MetricDimension]'}, - 'additional_dimensions': {'key': 'additionalDimensions', 'type': '[MetricDimension]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCounter, self).__init__(**kwargs) - self.name = kwargs['name'] - self.instance = kwargs.get('instance', None) - self.dimension_filter = kwargs.get('dimension_filter', None) - self.additional_dimensions = kwargs.get('additional_dimensions', None) - - -class MetricCounterSet(msrest.serialization.Model): - """The metric counter set. - - All required parameters must be populated in order to send to Azure. - - :param counters: Required. The counters that should be collected in this set. - :type counters: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricCounter] - """ - - _validation = { - 'counters': {'required': True}, - } - - _attribute_map = { - 'counters': {'key': 'counters', 'type': '[MetricCounter]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCounterSet, self).__init__(**kwargs) - self.counters = kwargs['counters'] - - -class MetricDimension(msrest.serialization.Model): - """The metric dimension. - - All required parameters must be populated in order to send to Azure. - - :param source_type: Required. The dimension type. - :type source_type: str - :param source_name: Required. The dimension value. - :type source_name: str - """ - - _validation = { - 'source_type': {'required': True}, - 'source_name': {'required': True}, - } - - _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'source_name': {'key': 'sourceName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) - self.source_type = kwargs['source_type'] - self.source_name = kwargs['source_name'] - - -class MetricDimensionV1(msrest.serialization.Model): - """Metric Dimension v1. - - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimensionV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecificationV1(msrest.serialization.Model): - """Metric specification version 1. - - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or - ~azure.mgmt.databoxedge.v2020_09_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or - ~azure.mgmt.databoxedge.v2020_09_01.models.MetricAggregationType] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.dimensions = kwargs.get('dimensions', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - - -class MonitoringMetricConfiguration(ARMBaseModel): - """The metric setting details for the role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param metric_configurations: Required. The metrics configuration details. - :type metric_configurations: - list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricConfiguration] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'metric_configurations': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metric_configurations': {'key': 'properties.metricConfigurations', 'type': '[MetricConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfiguration, self).__init__(**kwargs) - self.metric_configurations = kwargs['metric_configurations'] - - -class MonitoringMetricConfigurationList(msrest.serialization.Model): - """Collection of metric configurations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of metric configurations. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MonitoringMetricConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfigurationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class MountPointMap(msrest.serialization.Model): - """The share mount point. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str - :ivar role_id: ID of the role to which share is mounted. - :vartype role_id: str - :ivar mount_point: Mount point for the share. - :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". - :vartype mount_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive", - "MEC", "CloudEdgeManagement", "Kubernetes". - :vartype role_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes - """ - - _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.role_id = None - self.mount_point = None - self.mount_type = None - self.role_type = None - - -class NetworkAdapter(msrest.serialization.Model): - """Represents the networkAdapter on a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar adapter_id: Instance ID of network adapter. - :vartype adapter_id: str - :ivar adapter_position: Hardware position of network adapter. - :vartype adapter_position: ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterPosition - :ivar index: Logical index of the adapter. - :vartype index: int - :ivar node_id: Node ID of the network adapter. - :vartype node_id: str - :ivar network_adapter_name: Network adapter name. - :vartype network_adapter_name: str - :ivar label: Hardware label for the adapter. - :vartype label: str - :ivar mac_address: MAC address. - :vartype mac_address: str - :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". - :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterDHCPStatus - :ivar ipv4_configuration: The IPv4 configuration of the network adapter. - :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2020_09_01.models.Ipv4Config - :ivar ipv6_configuration: The IPv6 configuration of the network adapter. - :vartype ipv6_configuration: ~azure.mgmt.databoxedge.v2020_09_01.models.Ipv6Config - :ivar ipv6_link_local_address: The IPv6 local address. - :vartype ipv6_link_local_address: str - :ivar dns_servers: The list of DNS Servers of the device. - :vartype dns_servers: list[str] - """ - - _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) - self.adapter_id = None - self.adapter_position = None - self.index = None - self.node_id = None - self.network_adapter_name = None - self.label = None - self.mac_address = None - self.link_speed = None - self.status = None - self.rdma_status = kwargs.get('rdma_status', None) - self.dhcp_status = kwargs.get('dhcp_status', None) - self.ipv4_configuration = None - self.ipv6_configuration = None - self.ipv6_link_local_address = None - self.dns_servers = None - - -class NetworkAdapterPosition(msrest.serialization.Model): - """The network adapter position. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". - :vartype network_group: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkGroup - :ivar port: The port. - :vartype port: int - """ - - _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, - } - - _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) - self.network_group = None - self.port = None - - -class NetworkSettings(ARMBaseModel): - """The network settings of a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar network_adapters: The network adapter list on the device. - :vartype network_adapters: list[~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapter] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) - self.network_adapters = None - - -class Node(ARMBaseModel): - """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) - self.node_status = None - self.node_chassis_serial_number = None - self.node_serial_number = None - self.node_display_name = None - self.node_friendly_software_version = None - self.node_hcs_version = None - self.node_instance_id = None - - -class NodeInfo(msrest.serialization.Model): - """Kubernetes node info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Node name. - :vartype name: str - :ivar type: Node type - Master/Worker. Possible values include: "Invalid", "Master", "Worker". - :vartype type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesNodeType - :param ip_configuration: IP Configuration of the Kubernetes node. - :type ip_configuration: - list[~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesIPConfiguration] - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_configuration': {'key': 'ipConfiguration', 'type': '[KubernetesIPConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeInfo, self).__init__(**kwargs) - self.name = None - self.type = None - self.ip_configuration = kwargs.get('ip_configuration', None) - - -class NodeList(msrest.serialization.Model): - """Collection of Nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Nodes. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Node] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class Operation(msrest.serialization.Model): - """Operations. - - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2020_09_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2020_09_01.models.ServiceSpecification - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationDisplay(msrest.serialization.Model): - """Operation display properties. - - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str - """ - - _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 = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """The list of operations used for the discovery of available provider operations. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class Order(ARMBaseModel): - """The order details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2020_09_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2020_09_01.models.Address - :ivar current_status: Current status of the order. - :vartype current_status: ~azure.mgmt.databoxedge.v2020_09_01.models.OrderStatus - :ivar order_history: List of status changes in the order. - :vartype order_history: list[~azure.mgmt.databoxedge.v2020_09_01.models.OrderStatus] - :ivar serial_number: Serial number of the device. - :vartype serial_number: str - :ivar delivery_tracking_info: Tracking information for the package delivered to the customer - whether it has an original or a replacement device. - :vartype delivery_tracking_info: list[~azure.mgmt.databoxedge.v2020_09_01.models.TrackingInfo] - :ivar return_tracking_info: Tracking information for the package returned from the customer - whether it has an original or a replacement device. - :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2020_09_01.models.TrackingInfo] - :param shipment_type: ShipmentType of the order. Possible values include: "NotApplicable", - "ShippedToCustomer", "SelfPickup". - :type shipment_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShipmentType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'current_status': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - 'shipment_type': {'key': 'properties.shipmentType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Order, self).__init__(**kwargs) - self.contact_information = kwargs.get('contact_information', None) - self.shipping_address = kwargs.get('shipping_address', None) - self.current_status = None - self.order_history = None - self.serial_number = None - self.delivery_tracking_info = None - self.return_tracking_info = None - self.shipment_type = kwargs.get('shipment_type', None) - - -class OrderList(msrest.serialization.Model): - """List of order entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of orders. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Order] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OrderStatus(msrest.serialization.Model): - """Represents a single status change. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", - "AwaitingPickup", "PickupCompleted", "AwaitingDrop". - :type status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.OrderState - :ivar update_date_time: Time of status update. - :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str - :ivar tracking_information: Tracking information related to the state in the ordering flow. - :vartype tracking_information: ~azure.mgmt.databoxedge.v2020_09_01.models.TrackingInfo - :ivar additional_order_details: Dictionary to hold generic information which is not stored - by the already existing properties. - :vartype additional_order_details: dict[str, str] - """ - - _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'tracking_information': {'readonly': True}, - 'additional_order_details': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'tracking_information': {'key': 'trackingInformation', 'type': 'TrackingInfo'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) - self.status = kwargs['status'] - self.update_date_time = None - self.comments = kwargs.get('comments', None) - self.tracking_information = None - self.additional_order_details = None - - -class PeriodicTimerEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2020_09_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2020_09_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class PeriodicTimerSourceInfo(msrest.serialization.Model): - """Periodic timer event source. - - All required parameters must be populated in order to send to Azure. - - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str - """ - - _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) - self.start_time = kwargs['start_time'] - self.schedule = kwargs['schedule'] - self.topic = kwargs.get('topic', None) - - -class RefreshDetails(msrest.serialization.Model): - """Fields for tracking refresh job on the share or container. - - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or - container, this field indicates the ARM resource ID of that job. The field is empty if no job - is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh - job on this particular share or container, if any. This could be a failed job or a successful - job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or - container,if any. This could be a failed job or a successful job. - :type last_job: str - """ - - _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RefreshDetails, self).__init__(**kwargs) - self.in_progress_refresh_job_id = kwargs.get('in_progress_refresh_job_id', None) - self.last_completed_refresh_job_time_in_utc = kwargs.get('last_completed_refresh_job_time_in_utc', None) - self.error_manifest_file = kwargs.get('error_manifest_file', None) - self.last_job = kwargs.get('last_job', None) - - -class ResourceIdentity(msrest.serialization.Model): - """Msi identity details of the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param type: Identity type. Possible values include: "None", "SystemAssigned", "UserAssigned". - :type type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MsiIdentityType - :ivar principal_id: Service Principal Id backing the Msi. - :vartype principal_id: str - :ivar tenant_id: Home Tenant Id. - :vartype tenant_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.principal_id = None - self.tenant_id = None - - -class ResourceMoveDetails(msrest.serialization.Model): - """Fields for tracking resource move. - - :param operation_in_progress: Denotes whether move operation is in progress. Possible values - include: "None", "ResourceMoveInProgress", "ResourceMoveFailed". - :type operation_in_progress: str or - ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceMoveStatus - :param operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to - finish. - :type operation_in_progress_lock_timeout_in_utc: ~datetime.datetime - """ - - _attribute_map = { - 'operation_in_progress': {'key': 'operationInProgress', 'type': 'str'}, - 'operation_in_progress_lock_timeout_in_utc': {'key': 'operationInProgressLockTimeoutInUTC', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceMoveDetails, self).__init__(**kwargs) - self.operation_in_progress = kwargs.get('operation_in_progress', None) - self.operation_in_progress_lock_timeout_in_utc = kwargs.get('operation_in_progress_lock_timeout_in_utc', None) - - -class ResourceTypeSku(msrest.serialization.Model): - """Resource type Sku object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The resource type. - :vartype resource_type: str - :ivar skus: The skus. - :vartype skus: list[~azure.mgmt.databoxedge.v2020_09_01.models.SkuInformation] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'skus': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'skus': {'key': 'skus', 'type': '[SkuInformation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) - self.resource_type = None - self.skus = None - - -class RoleList(msrest.serialization.Model): - """Collection of all the roles on the Data Box Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Role] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RoleSinkInfo(msrest.serialization.Model): - """Compute role against which events will be raised. - - All required parameters must be populated in order to send to Azure. - - :param role_id: Required. Compute role ID. - :type role_id: str - """ - - _validation = { - 'role_id': {'required': True}, - } - - _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) - self.role_id = kwargs['role_id'] - - -class SecuritySettings(ARMBaseModel): - """The security settings of a device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: - ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) - self.device_admin_password = kwargs['device_admin_password'] - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification. - - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: - list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricSpecificationV1] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Share(ARMBaseModel): - """Represents a share on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Share on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share - (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the - share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2020_09_01.models.RefreshDetails - :ivar share_mappings: Share mount point to the role. - :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Share, self).__init__(**kwargs) - self.system_data = None - self.description = kwargs.get('description', None) - self.share_status = kwargs['share_status'] - self.monitoring_status = kwargs['monitoring_status'] - self.azure_container_info = kwargs.get('azure_container_info', None) - self.access_protocol = kwargs['access_protocol'] - self.user_access_rights = kwargs.get('user_access_rights', None) - self.client_access_rights = kwargs.get('client_access_rights', None) - self.refresh_details = kwargs.get('refresh_details', None) - self.share_mappings = None - self.data_policy = kwargs.get('data_policy', None) - - -class ShareAccessRight(msrest.serialization.Model): - """Specifies the mapping between this particular user and the type of access he has on shares on this device. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessType - """ - - _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.access_type = kwargs['access_type'] - - -class ShareList(msrest.serialization.Model): - """Collection of all the shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of shares. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Share] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Sku(msrest.serialization.Model): - """The SKU type. - - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". - :type name: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuTier - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - - -class SkuCost(msrest.serialization.Model): - """The metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The cost quantity. - :vartype quantity: long - :ivar extended_unit: The extended unit. - :vartype extended_unit: str - """ - - _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, - } - - _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) - self.meter_id = None - self.quantity = None - self.extended_unit = None - - -class SkuInformation(msrest.serialization.Model): - """Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: The sku tier. - :vartype tier: str - :ivar kind: The sku kind. - :vartype kind: str - :ivar family: The Sku family. - :vartype family: str - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2020_09_01.models.SkuCost] - :ivar locations: The locations where Sku is available. - :vartype locations: list[str] - :ivar location_info: The locations where Sku is available with zones and sites info. - :vartype location_info: list[~azure.mgmt.databoxedge.v2020_09_01.models.SkuLocationInfo] - :ivar required_quota_ids: The required quotaIds for the sku to be available. - :vartype required_quota_ids: list[str] - :ivar required_features: The required features for the sku to be available. - :vartype required_features: list[str] - """ - - _validation = { - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'family': {'readonly': True}, - 'costs': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) - self.name = None - self.tier = None - self.kind = None - self.family = None - self.costs = None - self.locations = None - self.location_info = None - self.required_quota_ids = None - self.required_features = None - - -class SkuInformationList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceTypeSku objects. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.ResourceTypeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SkuLocationInfo(msrest.serialization.Model): - """The location info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The location. - :vartype location: str - :ivar zones: The zones. - :vartype zones: list[str] - :ivar sites: The sites. - :vartype sites: list[str] - """ - - _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) - self.location = None - self.zones = None - self.sites = None - - -class StorageAccount(ARMBaseModel): - """Represents a Storage Account on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: StorageAccount object on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or - ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountStatus - :param data_policy: Required. Data policy of the storage Account. Possible values include: - "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str - :ivar blob_endpoint: BlobEndpoint of Storage Account. - :vartype blob_endpoint: str - :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy - set to Cloud. - :vartype container_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'data_policy': {'required': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccount, self).__init__(**kwargs) - self.system_data = None - self.description = kwargs.get('description', None) - self.storage_account_status = kwargs.get('storage_account_status', None) - self.data_policy = kwargs['data_policy'] - self.storage_account_credential_id = kwargs.get('storage_account_credential_id', None) - self.blob_endpoint = None - self.container_count = None - - -class StorageAccountCredential(ARMBaseModel): - """The storage account credential. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: StorageAccountCredential object. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredential, self).__init__(**kwargs) - self.system_data = None - self.alias = kwargs['alias'] - self.user_name = kwargs.get('user_name', None) - self.account_key = kwargs.get('account_key', None) - self.connection_string = kwargs.get('connection_string', None) - self.ssl_status = kwargs['ssl_status'] - self.blob_domain_name = kwargs.get('blob_domain_name', None) - self.account_type = kwargs['account_type'] - self.storage_account_id = kwargs.get('storage_account_id', None) - - -class StorageAccountCredentialList(msrest.serialization.Model): - """The collection of storage account credentials. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class StorageAccountList(msrest.serialization.Model): - """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of storageAccounts. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SubscriptionRegisteredFeatures(msrest.serialization.Model): - """SubscriptionRegisteredFeatures. - - :param name: - :type name: str - :param state: - :type state: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionRegisteredFeatures, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.state = kwargs.get('state', None) - - -class SymmetricKey(msrest.serialization.Model): - """Symmetric key for authentication. - - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret - """ - - _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) - self.connection_string = kwargs.get('connection_string', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type 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, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TrackingInfo(msrest.serialization.Model): - """Tracking courier information. - - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str - """ - - _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackingInfo, self).__init__(**kwargs) - self.serial_number = kwargs.get('serial_number', None) - self.carrier_name = kwargs.get('carrier_name', None) - self.tracking_id = kwargs.get('tracking_id', None) - self.tracking_url = kwargs.get('tracking_url', None) - - -class TriggerList(msrest.serialization.Model): - """Collection of all trigger on the data box edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of triggers. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Trigger] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UpdateDownloadProgress(msrest.serialization.Model): - """Details about the download progress of update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". - :vartype download_phase: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DownloadPhase - :ivar percent_complete: Percentage of completion. - :vartype percent_complete: int - :ivar total_bytes_to_download: Total bytes to download. - :vartype total_bytes_to_download: float - :ivar total_bytes_downloaded: Total bytes downloaded. - :vartype total_bytes_downloaded: float - :ivar number_of_updates_to_download: Number of updates to download. - :vartype number_of_updates_to_download: int - :ivar number_of_updates_downloaded: Number of updates downloaded. - :vartype number_of_updates_downloaded: int - """ - - _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, - } - - _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) - self.download_phase = None - self.percent_complete = None - self.total_bytes_to_download = None - self.total_bytes_downloaded = None - self.number_of_updates_to_download = None - self.number_of_updates_downloaded = None - - -class UpdateInstallProgress(msrest.serialization.Model): - """Progress details during installation of updates. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar percent_complete: Percentage completed. - :vartype percent_complete: int - :ivar number_of_updates_to_install: Number of updates to install. - :vartype number_of_updates_to_install: int - :ivar number_of_updates_installed: Number of updates installed. - :vartype number_of_updates_installed: int - """ - - _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, - } - - _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) - self.percent_complete = None - self.number_of_updates_to_install = None - self.number_of_updates_installed = None - - -class UpdateSummary(ARMBaseModel): - """Details about ongoing updates and availability of updates on the device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed - (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime - :ivar last_completed_download_job_date_time: The time when the last Download job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_download_job_date_time: ~datetime.datetime - :ivar last_completed_install_job_date_time: The time when the last Install job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_install_job_date_time: ~datetime.datetime - :ivar total_number_of_updates_available: The number of updates available for the current device - version as per the last device scan. - :vartype total_number_of_updates_available: int - :ivar total_number_of_updates_pending_download: The total number of items pending download. - :vartype total_number_of_updates_pending_download: int - :ivar total_number_of_updates_pending_install: The total number of items pending install. - :vartype total_number_of_updates_pending_install: int - :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.databoxedge.v2020_09_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". - :vartype ongoing_update_operation: str or - ~azure.mgmt.databoxedge.v2020_09_01.models.UpdateOperation - :ivar in_progress_download_job_id: The job ID of the download job in progress. - :vartype in_progress_download_job_id: str - :ivar in_progress_install_job_id: The job ID of the install job in progress. - :vartype in_progress_install_job_id: str - :ivar in_progress_download_job_started_date_time: The time when the currently running download - (if any) started. - :vartype in_progress_download_job_started_date_time: ~datetime.datetime - :ivar in_progress_install_job_started_date_time: The time when the currently running install - (if any) started. - :vartype in_progress_install_job_started_date_time: ~datetime.datetime - :ivar update_titles: The list of updates available for install. - :vartype update_titles: list[str] - :ivar total_update_size_in_bytes: The total size of updates available for download in bytes. - :vartype total_update_size_in_bytes: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateSummary, self).__init__(**kwargs) - self.device_version_number = kwargs.get('device_version_number', None) - self.friendly_device_version_name = kwargs.get('friendly_device_version_name', None) - self.device_last_scanned_date_time = kwargs.get('device_last_scanned_date_time', None) - self.last_completed_scan_job_date_time = kwargs.get('last_completed_scan_job_date_time', None) - self.last_completed_download_job_date_time = None - self.last_completed_install_job_date_time = None - self.total_number_of_updates_available = None - self.total_number_of_updates_pending_download = None - self.total_number_of_updates_pending_install = None - self.reboot_behavior = None - self.ongoing_update_operation = None - self.in_progress_download_job_id = None - self.in_progress_install_job_id = None - self.in_progress_download_job_started_date_time = None - self.in_progress_install_job_started_date_time = None - self.update_titles = None - self.total_update_size_in_bytes = None - - -class UploadCertificateRequest(msrest.serialization.Model): - """The upload certificate request. - - All required parameters must be populated in order to send to Azure. - - :param authentication_type: The authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str - """ - - _validation = { - 'certificate': {'required': True}, - } - - _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) - self.authentication_type = kwargs.get('authentication_type', None) - self.certificate = kwargs['certificate'] - - -class UploadCertificateResponse(msrest.serialization.Model): - """The upload registration certificate response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param auth_type: Specifies authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AuthenticationType - :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. - :vartype resource_id: str - :ivar aad_authority: Azure Active Directory tenant authority. - :vartype aad_authority: str - :ivar aad_tenant_id: Azure Active Directory tenant ID. - :vartype aad_tenant_id: str - :ivar service_principal_client_id: Azure Active Directory service principal client ID. - :vartype service_principal_client_id: str - :ivar service_principal_object_id: Azure Active Directory service principal object ID. - :vartype service_principal_object_id: str - :ivar azure_management_endpoint_audience: The azure management endpoint audience. - :vartype azure_management_endpoint_audience: str - :ivar aad_audience: Identifier of the target resource that is the recipient of the requested - token. - :vartype aad_audience: str - """ - - _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, - } - - _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) - self.auth_type = kwargs.get('auth_type', None) - self.resource_id = None - self.aad_authority = None - self.aad_tenant_id = None - self.service_principal_client_id = None - self.service_principal_object_id = None - self.azure_management_endpoint_audience = None - self.aad_audience = None - - -class User(ARMBaseModel): - """Represents a user who has access to one or more shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: User in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret - :ivar share_access_rights: List of shares that the user has rights on. This field should not be - specified during user creation. - :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessRight] - :param user_type: Type of the user. Possible values include: "Share", "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.UserType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_access_rights': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.system_data = None - self.encrypted_password = kwargs.get('encrypted_password', None) - self.share_access_rights = None - self.user_type = kwargs.get('user_type', None) - - -class UserAccessRight(msrest.serialization.Model): - """The mapping between a particular user and the access type on the SMB share. - - All required parameters must be populated in order to send to Azure. - - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessType - """ - - _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) - self.user_id = kwargs['user_id'] - self.access_type = kwargs['access_type'] - - -class UserList(msrest.serialization.Model): - """Collection of users. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of users. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.User] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) - self.value = None - self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_models_py3.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_models_py3.py index 3940676b4046..98a4eb6834fe 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_models_py3.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._data_box_edge_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ARMBaseModel(msrest.serialization.Model): +class ARMBaseModel(_serialization.Model): """Represents the base class for all object models. Variables are only populated by the server, and will be ignored when sending a request. @@ -28,22 +31,20 @@ class ARMBaseModel(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -52,8 +53,8 @@ def __init__( class Addon(ARMBaseModel): """Role Addon. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ArcAddon, IoTAddon. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ArcAddon, IoTAddon Variables are only populated by the server, and will be ignored when sending a request. @@ -65,43 +66,38 @@ class Addon(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - _subtype_map = { - 'kind': {'ArcForKubernetes': 'ArcAddon', 'IotEdge': 'IoTAddon'} - } + _subtype_map = {"kind": {"ArcForKubernetes": "ArcAddon", "IotEdge": "IoTAddon"}} - def __init__( - self, - **kwargs - ): - super(Addon, self).__init__(**kwargs) - self.kind = 'Addon' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None self.system_data = None -class AddonList(msrest.serialization.Model): +class AddonList(_serialization.Model): """Collection of all the Role addon on the Azure Stack Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -113,57 +109,55 @@ class AddonList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Addon]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Address(msrest.serialization.Model): +class Address(_serialization.Model): """The shipping address of the customer. All required parameters must be populated in order to send to Azure. - :param address_line1: The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: The postal code. - :type postal_code: str - :param city: The city name. - :type city: str - :param state: The state name. - :type state: str - :param country: Required. The country name. - :type country: str + :ivar address_line1: The address line1. + :vartype address_line1: str + :ivar address_line2: The address line2. + :vartype address_line2: str + :ivar address_line3: The address line3. + :vartype address_line3: str + :ivar postal_code: The postal code. + :vartype postal_code: str + :ivar city: The city name. + :vartype city: str + :ivar state: The state name. + :vartype state: str + :ivar country: The country name. Required. + :vartype country: str """ _validation = { - 'country': {'required': True}, + "country": {"required": True}, } _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, + "address_line1": {"key": "addressLine1", "type": "str"}, + "address_line2": {"key": "addressLine2", "type": "str"}, + "address_line3": {"key": "addressLine3", "type": "str"}, + "postal_code": {"key": "postalCode", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "country": {"key": "country", "type": "str"}, } def __init__( @@ -178,7 +172,23 @@ def __init__( state: Optional[str] = None, **kwargs ): - super(Address, self).__init__(**kwargs) + """ + :keyword address_line1: The address line1. + :paramtype address_line1: str + :keyword address_line2: The address line2. + :paramtype address_line2: str + :keyword address_line3: The address line3. + :paramtype address_line3: str + :keyword postal_code: The postal code. + :paramtype postal_code: str + :keyword city: The city name. + :paramtype city: str + :keyword state: The state name. + :paramtype state: str + :keyword country: The country name. Required. + :paramtype country: str + """ + super().__init__(**kwargs) self.address_line1 = address_line1 self.address_line2 = address_line2 self.address_line3 = address_line3 @@ -188,7 +198,7 @@ def __init__( self.country = country -class Alert(ARMBaseModel): +class Alert(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Alert on the data box edge/gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -209,7 +219,7 @@ class Alert(ARMBaseModel): :vartype appeared_at_date_time: ~datetime.datetime :ivar recommendation: Alert recommendation. :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", + :ivar severity: Severity of the alert. Known values are: "Informational", "Warning", and "Critical". :vartype severity: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AlertSeverity :ivar error_details: Error details of the alert. @@ -219,38 +229,36 @@ class Alert(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "title": {"readonly": True}, + "alert_type": {"readonly": True}, + "appeared_at_date_time": {"readonly": True}, + "recommendation": {"readonly": True}, + "severity": {"readonly": True}, + "error_details": {"readonly": True}, + "detailed_information": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "title": {"key": "properties.title", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "appeared_at_date_time": {"key": "properties.appearedAtDateTime", "type": "iso-8601"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "error_details": {"key": "properties.errorDetails", "type": "AlertErrorDetails"}, + "detailed_information": {"key": "properties.detailedInformation", "type": "{str}"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None self.title = None self.alert_type = None @@ -261,7 +269,7 @@ def __init__( self.detailed_information = None -class AlertErrorDetails(msrest.serialization.Model): +class AlertErrorDetails(_serialization.Model): """Error details for the alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -275,28 +283,26 @@ class AlertErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, + "error_code": {"readonly": True}, + "error_message": {"readonly": True}, + "occurrences": {"readonly": True}, } _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "occurrences": {"key": "occurrences", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_code = None self.error_message = None self.occurrences = None -class AlertList(msrest.serialization.Model): +class AlertList(_serialization.Model): """Collection of alerts. Variables are only populated by the server, and will be ignored when sending a request. @@ -308,25 +314,23 @@ class AlertList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ArcAddon(Addon): +class ArcAddon(Addon): # pylint: disable=too-many-instance-attributes """Arc Addon. Variables are only populated by the server, and will be ignored when sending a request. @@ -339,75 +343,78 @@ class ArcAddon(Addon): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param subscription_id: Required. Arc resource subscription Id. - :type subscription_id: str - :param resource_group_name: Required. Arc resource group name. - :type resource_group_name: str - :param resource_name: Required. Arc resource Name. - :type resource_name: str - :param resource_location: Required. Arc resource location. - :type resource_location: str + :ivar subscription_id: Arc resource subscription Id. Required. + :vartype subscription_id: str + :ivar resource_group_name: Arc resource group name. Required. + :vartype resource_group_name: str + :ivar resource_name: Arc resource Name. Required. + :vartype resource_name: str + :ivar resource_location: Arc resource location. Required. + :vartype resource_location: str :ivar version: Arc resource version. :vartype version: str - :ivar host_platform: Host OS supported by the Arc addon. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the Arc addon. Known values are: "Windows" and "Linux". :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'subscription_id': {'required': True}, - 'resource_group_name': {'required': True}, - 'resource_name': {'required': True}, - 'resource_location': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "subscription_id": {"required": True}, + "resource_group_name": {"required": True}, + "resource_name": {"required": True}, + "resource_location": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'properties.resourceGroupName', 'type': 'str'}, - 'resource_name': {'key': 'properties.resourceName', 'type': 'str'}, - 'resource_location': {'key': 'properties.resourceLocation', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "subscription_id": {"key": "properties.subscriptionId", "type": "str"}, + "resource_group_name": {"key": "properties.resourceGroupName", "type": "str"}, + "resource_name": {"key": "properties.resourceName", "type": "str"}, + "resource_location": {"key": "properties.resourceLocation", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( - self, - *, - subscription_id: str, - resource_group_name: str, - resource_name: str, - resource_location: str, - **kwargs + self, *, subscription_id: str, resource_group_name: str, resource_name: str, resource_location: str, **kwargs ): - super(ArcAddon, self).__init__(**kwargs) - self.kind = 'ArcForKubernetes' # type: str + """ + :keyword subscription_id: Arc resource subscription Id. Required. + :paramtype subscription_id: str + :keyword resource_group_name: Arc resource group name. Required. + :paramtype resource_group_name: str + :keyword resource_name: Arc resource Name. Required. + :paramtype resource_name: str + :keyword resource_location: Arc resource location. Required. + :paramtype resource_location: str + """ + super().__init__(**kwargs) + self.kind: str = "ArcForKubernetes" self.subscription_id = subscription_id self.resource_group_name = resource_group_name self.resource_name = resource_name @@ -418,94 +425,105 @@ def __init__( self.provisioning_state = None -class AsymmetricEncryptedSecret(msrest.serialization.Model): +class AsymmetricEncryptedSecret(_serialization.Model): """Represent the secrets intended for encryption with asymmetric key pair. All required parameters must be populated in order to send to Azure. - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + :ivar value: The value of the secret. Required. + :vartype value: str + :ivar encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or + :vartype encryption_cert_thumbprint: str + :ivar encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values are: + "None", "AES256", and "RSAES_PKCS1_v_1_5". + :vartype encryption_algorithm: str or ~azure.mgmt.databoxedge.v2020_09_01.models.EncryptionAlgorithm """ _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, + "value": {"required": True}, + "encryption_algorithm": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "encryption_cert_thumbprint": {"key": "encryptionCertThumbprint", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, } def __init__( self, *, value: str, - encryption_algorithm: Union[str, "EncryptionAlgorithm"], + encryption_algorithm: Union[str, "_models.EncryptionAlgorithm"], encryption_cert_thumbprint: Optional[str] = None, **kwargs ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) + """ + :keyword value: The value of the secret. Required. + :paramtype value: str + :keyword encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :paramtype encryption_cert_thumbprint: str + :keyword encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values + are: "None", "AES256", and "RSAES_PKCS1_v_1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.EncryptionAlgorithm + """ + super().__init__(**kwargs) self.value = value self.encryption_cert_thumbprint = encryption_cert_thumbprint self.encryption_algorithm = encryption_algorithm -class Authentication(msrest.serialization.Model): +class Authentication(_serialization.Model): """Authentication mechanism for IoT devices. - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2020_09_01.models.SymmetricKey + :ivar symmetric_key: Symmetric key for authentication. + :vartype symmetric_key: ~azure.mgmt.databoxedge.v2020_09_01.models.SymmetricKey """ _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, + "symmetric_key": {"key": "symmetricKey", "type": "SymmetricKey"}, } - def __init__( - self, - *, - symmetric_key: Optional["SymmetricKey"] = None, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) + def __init__(self, *, symmetric_key: Optional["_models.SymmetricKey"] = None, **kwargs): + """ + :keyword symmetric_key: Symmetric key for authentication. + :paramtype symmetric_key: ~azure.mgmt.databoxedge.v2020_09_01.models.SymmetricKey + """ + super().__init__(**kwargs) self.symmetric_key = symmetric_key -class AzureContainerInfo(msrest.serialization.Model): +class AzureContainerInfo(_serialization.Model): """Azure container mapping of the endpoint. All required parameters must be populated in order to send to Azure. - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerDataFormat + :ivar storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :vartype storage_account_credential_id: str + :ivar container_name: Container name (Based on the data format specified, this represents the + name of Azure Files/Page blob/Block blob). Required. + :vartype container_name: str + :ivar data_format: Storage format used for the file represented by the share. Required. Known + values are: "BlockBlob", "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerDataFormat """ _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, + "storage_account_credential_id": {"required": True}, + "container_name": {"required": True}, + "data_format": {"required": True}, } _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, + "storage_account_credential_id": {"key": "storageAccountCredentialId", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "data_format": {"key": "dataFormat", "type": "str"}, } def __init__( @@ -513,10 +531,22 @@ def __init__( *, storage_account_credential_id: str, container_name: str, - data_format: Union[str, "AzureContainerDataFormat"], + data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs ): - super(AzureContainerInfo, self).__init__(**kwargs) + """ + :keyword storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :paramtype storage_account_credential_id: str + :keyword container_name: Container name (Based on the data format specified, this represents + the name of Azure Files/Page blob/Block blob). Required. + :paramtype container_name: str + :keyword data_format: Storage format used for the file represented by the share. Required. + Known values are: "BlockBlob", "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.storage_account_credential_id = storage_account_credential_id self.container_name = container_name self.data_format = data_format @@ -537,48 +567,52 @@ class BandwidthSchedule(ARMBaseModel): :vartype type: str :ivar system_data: Bandwidth object related to ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2020_09_01.models.DayOfWeek] + :ivar start: The start time of the schedule in UTC. Required. + :vartype start: str + :ivar stop: The stop time of the schedule in UTC. Required. + :vartype stop: str + :ivar rate_in_mbps: The bandwidth rate in Mbps. Required. + :vartype rate_in_mbps: int + :ivar days: The days of the week when this schedule is applicable. Required. + :vartype days: list[str or ~azure.mgmt.databoxedge.v2020_09_01.models.DayOfWeek] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "start": {"required": True}, + "stop": {"required": True}, + "rate_in_mbps": {"required": True}, + "days": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "start": {"key": "properties.start", "type": "str"}, + "stop": {"key": "properties.stop", "type": "str"}, + "rate_in_mbps": {"key": "properties.rateInMbps", "type": "int"}, + "days": {"key": "properties.days", "type": "[str]"}, } def __init__( - self, - *, - start: str, - stop: str, - rate_in_mbps: int, - days: List[Union[str, "DayOfWeek"]], - **kwargs + self, *, start: str, stop: str, rate_in_mbps: int, days: List[Union[str, "_models.DayOfWeek"]], **kwargs ): - super(BandwidthSchedule, self).__init__(**kwargs) + """ + :keyword start: The start time of the schedule in UTC. Required. + :paramtype start: str + :keyword stop: The stop time of the schedule in UTC. Required. + :paramtype stop: str + :keyword rate_in_mbps: The bandwidth rate in Mbps. Required. + :paramtype rate_in_mbps: int + :keyword days: The days of the week when this schedule is applicable. Required. + :paramtype days: list[str or ~azure.mgmt.databoxedge.v2020_09_01.models.DayOfWeek] + """ + super().__init__(**kwargs) self.system_data = None self.start = start self.stop = stop @@ -586,7 +620,7 @@ def __init__( self.days = days -class BandwidthSchedulesList(msrest.serialization.Model): +class BandwidthSchedulesList(_serialization.Model): """The collection of bandwidth schedules. Variables are only populated by the server, and will be ignored when sending a request. @@ -598,54 +632,55 @@ class BandwidthSchedulesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BandwidthSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ClientAccessRight(msrest.serialization.Model): +class ClientAccessRight(_serialization.Model): """The mapping between a particular client IP and the type of access client has on the NFS share. All required parameters must be populated in order to send to Azure. - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ClientPermissionType + :ivar client: IP of the client. Required. + :vartype client: str + :ivar access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :vartype access_permission: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.ClientPermissionType """ _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, + "client": {"required": True}, + "access_permission": {"required": True}, } _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - *, - client: str, - access_permission: Union[str, "ClientPermissionType"], - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) + "client": {"key": "client", "type": "str"}, + "access_permission": {"key": "accessPermission", "type": "str"}, + } + + def __init__(self, *, client: str, access_permission: Union[str, "_models.ClientPermissionType"], **kwargs): + """ + :keyword client: IP of the client. Required. + :paramtype client: str + :keyword access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :paramtype access_permission: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.ClientPermissionType + """ + super().__init__(**kwargs) self.client = client self.access_permission = access_permission @@ -653,8 +688,8 @@ def __init__( class Role(ARMBaseModel): """Compute role. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole Variables are only populated by the server, and will be ignored when sending a request. @@ -666,39 +701,42 @@ class Role(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } _subtype_map = { - 'kind': {'CloudEdgeManagement': 'CloudEdgeManagementRole', 'IOT': 'IoTRole', 'Kubernetes': 'KubernetesRole', 'MEC': 'MECRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str + "kind": { + "CloudEdgeManagement": "CloudEdgeManagementRole", + "IOT": "IoTRole", + "Kubernetes": "KubernetesRole", + "MEC": "MECRole", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None self.system_data = None @@ -715,71 +753,70 @@ class CloudEdgeManagementRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :ivar local_management_status: Local Edge Management Status. Possible values include: - "Enabled", "Disabled". + :ivar local_management_status: Local Edge Management Status. Known values are: "Enabled" and + "Disabled". :vartype local_management_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus :ivar edge_profile: Edge Profile of the resource. :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfile - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'local_management_status': {'readonly': True}, - 'edge_profile': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "local_management_status": {"readonly": True}, + "edge_profile": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'local_management_status': {'key': 'properties.localManagementStatus', 'type': 'str'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - *, - role_status: Optional[Union[str, "RoleStatus"]] = None, - **kwargs - ): - super(CloudEdgeManagementRole, self).__init__(**kwargs) - self.kind = 'CloudEdgeManagement' # type: str + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "local_management_status": {"key": "properties.localManagementStatus", "type": "str"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, + } + + def __init__(self, *, role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs): + """ + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "CloudEdgeManagement" self.local_management_status = None self.edge_profile = None self.role_status = role_status -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2020_09_01.models.CloudErrorBody] + :vartype message: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.databoxedge.v2020_09_01.models.CloudErrorBody] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -787,16 +824,26 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): - super(CloudErrorBody, self).__init__(**kwargs) + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.databoxedge.v2020_09_01.models.CloudErrorBody] + """ + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class CniConfig(msrest.serialization.Model): +class CniConfig(_serialization.Model): """Cni configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -812,102 +859,102 @@ class CniConfig(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - 'pod_subnet': {'readonly': True}, - 'service_subnet': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, + "pod_subnet": {"readonly": True}, + "service_subnet": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'pod_subnet': {'key': 'podSubnet', 'type': 'str'}, - 'service_subnet': {'key': 'serviceSubnet', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "pod_subnet": {"key": "podSubnet", "type": "str"}, + "service_subnet": {"key": "serviceSubnet", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(CniConfig, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None self.pod_subnet = None self.service_subnet = None -class ComputeResource(msrest.serialization.Model): +class ComputeResource(_serialization.Model): """Compute infrastructure Resource. All required parameters must be populated in order to send to Azure. - :param processor_count: Required. Processor count. - :type processor_count: int - :param memory_in_gb: Required. Memory in GB. - :type memory_in_gb: long + :ivar processor_count: Processor count. Required. + :vartype processor_count: int + :ivar memory_in_gb: Memory in GB. Required. + :vartype memory_in_gb: int """ _validation = { - 'processor_count': {'required': True}, - 'memory_in_gb': {'required': True}, + "processor_count": {"required": True}, + "memory_in_gb": {"required": True}, } _attribute_map = { - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'long'}, - } - - def __init__( - self, - *, - processor_count: int, - memory_in_gb: int, - **kwargs - ): - super(ComputeResource, self).__init__(**kwargs) + "processor_count": {"key": "processorCount", "type": "int"}, + "memory_in_gb": {"key": "memoryInGB", "type": "int"}, + } + + def __init__(self, *, processor_count: int, memory_in_gb: int, **kwargs): + """ + :keyword processor_count: Processor count. Required. + :paramtype processor_count: int + :keyword memory_in_gb: Memory in GB. Required. + :paramtype memory_in_gb: int + """ + super().__init__(**kwargs) self.processor_count = processor_count self.memory_in_gb = memory_in_gb -class ContactDetails(msrest.serialization.Model): +class ContactDetails(_serialization.Model): """Contains all the contact details of the customer. All required parameters must be populated in order to send to Azure. - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] + :ivar contact_person: The contact person name. Required. + :vartype contact_person: str + :ivar company_name: The name of the company. Required. + :vartype company_name: str + :ivar phone: The phone number. Required. + :vartype phone: str + :ivar email_list: The email list. Required. + :vartype email_list: list[str] """ _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, + "contact_person": {"required": True}, + "company_name": {"required": True}, + "phone": {"required": True}, + "email_list": {"required": True}, } _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - *, - contact_person: str, - company_name: str, - phone: str, - email_list: List[str], - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) + "contact_person": {"key": "contactPerson", "type": "str"}, + "company_name": {"key": "companyName", "type": "str"}, + "phone": {"key": "phone", "type": "str"}, + "email_list": {"key": "emailList", "type": "[str]"}, + } + + def __init__(self, *, contact_person: str, company_name: str, phone: str, email_list: List[str], **kwargs): + """ + :keyword contact_person: The contact person name. Required. + :paramtype contact_person: str + :keyword company_name: The name of the company. Required. + :paramtype company_name: str + :keyword phone: The phone number. Required. + :paramtype phone: str + :keyword email_list: The email list. Required. + :paramtype email_list: list[str] + """ + super().__init__(**kwargs) self.contact_person = contact_person self.company_name = company_name self.phone = phone @@ -929,12 +976,13 @@ class Container(ARMBaseModel): :vartype type: str :ivar system_data: Container in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". + :ivar container_status: Current status of the container. Known values are: "OK", "Offline", + "Unknown", "Updating", and "NeedsAttention". :vartype container_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerDataFormat + :ivar data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerDataFormat :ivar refresh_details: Details of the refresh job on this container. :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_09_01.models.RefreshDetails :ivar created_date_time: The UTC time when container got created. @@ -942,34 +990,35 @@ class Container(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "container_status": {"readonly": True}, + "data_format": {"required": True}, + "refresh_details": {"readonly": True}, + "created_date_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - data_format: Union[str, "AzureContainerDataFormat"], - **kwargs - ): - super(Container, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "container_status": {"key": "properties.containerStatus", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, + } + + def __init__(self, *, data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs): + """ + :keyword data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.system_data = None self.container_status = None self.data_format = data_format @@ -977,7 +1026,7 @@ def __init__( self.created_date_time = None -class ContainerList(msrest.serialization.Model): +class ContainerList(_serialization.Model): """Collection of all the containers on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -989,25 +1038,23 @@ class ContainerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Container]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevice(ARMBaseModel): +class DataBoxEdgeDevice(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1020,29 +1067,29 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure + :ivar location: The location of the device. This is a supported and registered Azure geographical region (for example, West US, East US, or Southeast Asia). The geographical region of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2020_09_01.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceIdentity - :ivar kind: The etag for the devices. Possible values include: "AzureDataBoxGateway", - "AzureStackEdge", "AzureStackHub", "AzureModularDataCentre". + specified on update, the request will succeed. Required. + :vartype location: str + :ivar tags: The list of tags that describe the device. These tags can be used to view and group + this device (across resource groups). + :vartype tags: dict[str, str] + :ivar sku: The SKU type. + :vartype sku: ~azure.mgmt.databoxedge.v2020_09_01.models.Sku + :ivar etag: The etag for the devices. + :vartype etag: str + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceIdentity + :ivar kind: The etag for the devices. Known values are: "AzureDataBoxGateway", + "AzureStackEdge", "AzureStackHub", and "AzureModularDataCentre". :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceKind :ivar system_data: DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or + :ivar data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known values + are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :vartype data_box_edge_device_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceStatus :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. :vartype serial_number: str @@ -1050,8 +1097,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype description: str :ivar model_description: The description of the Data Box Edge/Gateway device model. :vartype model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". + :ivar device_type: The type of the Data Box Edge/Gateway device. "DataBoxEdgeDevice" :vartype device_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DeviceType :ivar friendly_name: The Data Box Edge/Gateway device name. :vartype friendly_name: str @@ -1062,7 +1108,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :ivar device_software_version: The Data Box Edge/Gateway device software version. :vartype device_software_version: str :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long + :vartype device_local_capacity: int :ivar time_zone: The Data Box Edge/Gateway device timezone. :vartype time_zone: str :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). @@ -1079,70 +1125,91 @@ class DataBoxEdgeDevice(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'system_data': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'description': {'readonly': True}, - 'model_description': {'readonly': True}, - 'device_type': {'readonly': True}, - 'friendly_name': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'edge_profile': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"readonly": True}, + "system_data": {"readonly": True}, + "serial_number": {"readonly": True}, + "description": {"readonly": True}, + "model_description": {"readonly": True}, + "device_type": {"readonly": True}, + "friendly_name": {"readonly": True}, + "culture": {"readonly": True}, + "device_model": {"readonly": True}, + "device_software_version": {"readonly": True}, + "device_local_capacity": {"readonly": True}, + "time_zone": {"readonly": True}, + "device_hcs_version": {"readonly": True}, + "configured_role_types": {"readonly": True}, + "node_count": {"readonly": True}, + "resource_move_details": {"readonly": True}, + "edge_profile": {"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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - 'resource_move_details': {'key': 'properties.resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - } - - def __init__( + "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}"}, + "sku": {"key": "sku", "type": "Sku"}, + "etag": {"key": "etag", "type": "str"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "data_box_edge_device_status": {"key": "properties.dataBoxEdgeDeviceStatus", "type": "str"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "model_description": {"key": "properties.modelDescription", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "culture": {"key": "properties.culture", "type": "str"}, + "device_model": {"key": "properties.deviceModel", "type": "str"}, + "device_software_version": {"key": "properties.deviceSoftwareVersion", "type": "str"}, + "device_local_capacity": {"key": "properties.deviceLocalCapacity", "type": "int"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "device_hcs_version": {"key": "properties.deviceHcsVersion", "type": "str"}, + "configured_role_types": {"key": "properties.configuredRoleTypes", "type": "[str]"}, + "node_count": {"key": "properties.nodeCount", "type": "int"}, + "resource_move_details": {"key": "properties.resourceMoveDetails", "type": "ResourceMoveDetails"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, etag: Optional[str] = None, - identity: Optional["ResourceIdentity"] = None, - data_box_edge_device_status: Optional[Union[str, "DataBoxEdgeDeviceStatus"]] = None, + identity: Optional["_models.ResourceIdentity"] = None, + data_box_edge_device_status: Optional[Union[str, "_models.DataBoxEdgeDeviceStatus"]] = None, **kwargs ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) + """ + :keyword location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :paramtype location: str + :keyword tags: The list of tags that describe the device. These tags can be used to view and + group this device (across resource groups). + :paramtype tags: dict[str, str] + :keyword sku: The SKU type. + :paramtype sku: ~azure.mgmt.databoxedge.v2020_09_01.models.Sku + :keyword etag: The etag for the devices. + :paramtype etag: str + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceIdentity + :keyword data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known + values are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :paramtype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceStatus + """ + super().__init__(**kwargs) self.location = location self.tags = tags self.sku = sku @@ -1179,43 +1246,43 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to + :ivar encryption_key_thumbprint: The digital signature of encrypted certificate. + :vartype encryption_key_thumbprint: str + :ivar encryption_key: The public part of the encryption certificate. Client uses this to encrypt any secret. - :type encryption_key: str + :vartype encryption_key: str :ivar resource_key: The Resource ID of the Resource. :vartype resource_key: str - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_version: str + :vartype channel_integrity_key_version: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_key": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - 'client_secret_store_id': {'key': 'properties.clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'properties.clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'properties.channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'properties.channelIntegrityKeyVersion', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encryption_key_thumbprint": {"key": "properties.encryptionKeyThumbprint", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "str"}, + "resource_key": {"key": "properties.resourceKey", "type": "str"}, + "client_secret_store_id": {"key": "properties.clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "properties.clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "properties.channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "properties.channelIntegrityKeyVersion", "type": "str"}, } def __init__( @@ -1229,7 +1296,24 @@ def __init__( channel_integrity_key_version: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) + """ + :keyword encryption_key_thumbprint: The digital signature of encrypted certificate. + :paramtype encryption_key_thumbprint: str + :keyword encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :paramtype encryption_key: str + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + """ + super().__init__(**kwargs) self.encryption_key_thumbprint = encryption_key_thumbprint self.encryption_key = encryption_key self.resource_key = None @@ -1239,26 +1323,26 @@ def __init__( self.channel_integrity_key_version = channel_integrity_key_version -class DataBoxEdgeDeviceExtendedInfoPatch(msrest.serialization.Model): +class DataBoxEdgeDeviceExtendedInfoPatch(_serialization.Model): """The Data Box Edge/Gateway device extended info patch. - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_version: str + :vartype channel_integrity_key_version: str """ _attribute_map = { - 'client_secret_store_id': {'key': 'clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'channelIntegrityKeyVersion', 'type': 'str'}, + "client_secret_store_id": {"key": "clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "channelIntegrityKeyVersion", "type": "str"}, } def __init__( @@ -1270,14 +1354,26 @@ def __init__( channel_integrity_key_version: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfoPatch, self).__init__(**kwargs) + """ + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name for Channel Integrity Key stored in the Client + Key Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + """ + super().__init__(**kwargs) self.client_secret_store_id = client_secret_store_id self.client_secret_store_url = client_secret_store_url self.channel_integrity_key_name = channel_integrity_key_name self.channel_integrity_key_version = channel_integrity_key_version -class DataBoxEdgeDeviceList(msrest.serialization.Model): +class DataBoxEdgeDeviceList(_serialization.Model): """The collection of Data Box Edge/Gateway devices. Variables are only populated by the server, and will be ignored when sending a request. @@ -1289,103 +1385,109 @@ class DataBoxEdgeDeviceList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevicePatch(msrest.serialization.Model): +class DataBoxEdgeDevicePatch(_serialization.Model): """The Data Box Edge/Gateway device patch. - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceIdentity - :param edge_profile: Edge Profile property of the Data Box Edge/Gateway device. - :type edge_profile: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfilePatch + :ivar tags: The tags attached to the Data Box Edge/Gateway resource. + :vartype tags: dict[str, str] + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceIdentity + :ivar edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfilePatch """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfilePatch'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfilePatch"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["ResourceIdentity"] = None, - edge_profile: Optional["EdgeProfilePatch"] = None, + identity: Optional["_models.ResourceIdentity"] = None, + edge_profile: Optional["_models.EdgeProfilePatch"] = None, **kwargs ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) + """ + :keyword tags: The tags attached to the Data Box Edge/Gateway resource. + :paramtype tags: dict[str, str] + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceIdentity + :keyword edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :paramtype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfilePatch + """ + super().__init__(**kwargs) self.tags = tags self.identity = identity self.edge_profile = edge_profile -class DataBoxEdgeMoveRequest(msrest.serialization.Model): +class DataBoxEdgeMoveRequest(_serialization.Model): """Resource Move details. All required parameters must be populated in order to send to Azure. - :param target_resource_group: Required. Target resource group ARMId. - :type target_resource_group: str - :param resources: Required. List of resources to be moved. - :type resources: list[str] + :ivar target_resource_group: Target resource group ARMId. Required. + :vartype target_resource_group: str + :ivar resources: List of resources to be moved. Required. + :vartype resources: list[str] """ _validation = { - 'target_resource_group': {'required': True}, - 'resources': {'required': True}, + "target_resource_group": {"required": True}, + "resources": {"required": True}, } _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[str]'}, - } - - def __init__( - self, - *, - target_resource_group: str, - resources: List[str], - **kwargs - ): - super(DataBoxEdgeMoveRequest, self).__init__(**kwargs) + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, + "resources": {"key": "resources", "type": "[str]"}, + } + + def __init__(self, *, target_resource_group: str, resources: List[str], **kwargs): + """ + :keyword target_resource_group: Target resource group ARMId. Required. + :paramtype target_resource_group: str + :keyword resources: List of resources to be moved. Required. + :paramtype resources: list[str] + """ + super().__init__(**kwargs) self.target_resource_group = target_resource_group self.resources = resources -class DataBoxEdgeSku(msrest.serialization.Model): +class DataBoxEdgeSku(_serialization.Model): # pylint: disable=too-many-instance-attributes """The Sku information. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". + :ivar name: The Sku name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", and "RDC". :vartype name: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuName :ivar kind: The Sku kind. :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". + :ivar tier: The Sku tier. "Standard" :vartype tier: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuTier :ivar size: The Sku kind. :vartype size: str @@ -1399,13 +1501,13 @@ class DataBoxEdgeSku(msrest.serialization.Model): :vartype location_info: list[~azure.mgmt.databoxedge.v2020_09_01.models.SkuLocationInfo] :ivar costs: The pricing info of the Sku. :vartype costs: list[~azure.mgmt.databoxedge.v2020_09_01.models.SkuCost] - :ivar signup_option: Sku can be signed up by customer or not. Possible values include: "None", + :ivar signup_option: Sku can be signed up by customer or not. Known values are: "None" and "Available". :vartype signup_option: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuSignupOption - :ivar version: Availability of the Sku as preview/stable. Possible values include: "Stable", + :ivar version: Availability of the Sku as preview/stable. Known values are: "Stable" and "Preview". :vartype version: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuVersion - :ivar availability: Links to the next set of results. Possible values include: "Available", + :ivar availability: Links to the next set of results. Known values are: "Available" and "Unavailable". :vartype availability: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuAvailability :ivar shipment_types: List of Shipment Types supported by this SKU. @@ -1413,44 +1515,42 @@ class DataBoxEdgeSku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - 'shipment_types': {'readonly': True}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "kind": {"readonly": True}, + "tier": {"readonly": True}, + "size": {"readonly": True}, + "family": {"readonly": True}, + "locations": {"readonly": True}, + "api_versions": {"readonly": True}, + "location_info": {"readonly": True}, + "costs": {"readonly": True}, + "signup_option": {"readonly": True}, + "version": {"readonly": True}, + "availability": {"readonly": True}, + "shipment_types": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, - 'shipment_types': {'key': 'shipmentTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "signup_option": {"key": "signupOption", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "availability": {"key": "availability", "type": "str"}, + "shipment_types": {"key": "shipmentTypes", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.kind = None @@ -1467,7 +1567,7 @@ def __init__( self.shipment_types = None -class DataBoxEdgeSkuList(msrest.serialization.Model): +class DataBoxEdgeSkuList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -1479,143 +1579,163 @@ class DataBoxEdgeSkuList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DCAccessCode(msrest.serialization.Model): +class DCAccessCode(_serialization.Model): """DC Access code in the case of Self Managed Shipping. - :param auth_code: DCAccess Code for the Self Managed shipment. - :type auth_code: str + :ivar auth_code: DCAccess Code for the Self Managed shipment. + :vartype auth_code: str """ _attribute_map = { - 'auth_code': {'key': 'properties.authCode', 'type': 'str'}, + "auth_code": {"key": "properties.authCode", "type": "str"}, } - def __init__( - self, - *, - auth_code: Optional[str] = None, - **kwargs - ): - super(DCAccessCode, self).__init__(**kwargs) + def __init__(self, *, auth_code: Optional[str] = None, **kwargs): + """ + :keyword auth_code: DCAccess Code for the Self Managed shipment. + :paramtype auth_code: str + """ + super().__init__(**kwargs) self.auth_code = auth_code -class EdgeProfile(msrest.serialization.Model): +class EdgeProfile(_serialization.Model): """Details about Edge Profile for the resource. - :param subscription: Edge Profile Subscription. - :type subscription: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfileSubscription + :ivar subscription: Edge Profile Subscription. + :vartype subscription: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfileSubscription """ _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscription'}, + "subscription": {"key": "subscription", "type": "EdgeProfileSubscription"}, } - def __init__( - self, - *, - subscription: Optional["EdgeProfileSubscription"] = None, - **kwargs - ): - super(EdgeProfile, self).__init__(**kwargs) + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscription"] = None, **kwargs): + """ + :keyword subscription: Edge Profile Subscription. + :paramtype subscription: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfileSubscription + """ + super().__init__(**kwargs) self.subscription = subscription -class EdgeProfilePatch(msrest.serialization.Model): +class EdgeProfilePatch(_serialization.Model): """The Data Box Edge/Gateway Edge Profile patch. - :param subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. - :type subscription: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfileSubscriptionPatch + :ivar subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :vartype subscription: ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfileSubscriptionPatch """ _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscriptionPatch'}, + "subscription": {"key": "subscription", "type": "EdgeProfileSubscriptionPatch"}, } - def __init__( - self, - *, - subscription: Optional["EdgeProfileSubscriptionPatch"] = None, - **kwargs - ): - super(EdgeProfilePatch, self).__init__(**kwargs) + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscriptionPatch"] = None, **kwargs): + """ + :keyword subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :paramtype subscription: + ~azure.mgmt.databoxedge.v2020_09_01.models.EdgeProfileSubscriptionPatch + """ + super().__init__(**kwargs) self.subscription = subscription -class EdgeProfileSubscription(msrest.serialization.Model): +class EdgeProfileSubscription(_serialization.Model): """Subscription details for the Edge Profile. - :param registration_id: Edge Subscription Registration ID. - :type registration_id: str - :param id: ARM ID of the subscription. - :type id: str - :param state: Possible values include: "Registered", "Warned", "Suspended", "Deleted", + :ivar registration_id: Edge Subscription Registration ID. + :vartype registration_id: str + :ivar id: ARM ID of the subscription. + :vartype id: str + :ivar state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and "Unregistered". - :type state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SubscriptionState - :param registration_date: - :type registration_date: str - :param subscription_id: - :type subscription_id: str - :param tenant_id: - :type tenant_id: str - :param location_placement_id: - :type location_placement_id: str - :param quota_id: - :type quota_id: str - :param serialized_details: - :type serialized_details: str - :param registered_features: - :type registered_features: + :vartype state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SubscriptionState + :ivar registration_date: + :vartype registration_date: str + :ivar subscription_id: + :vartype subscription_id: str + :ivar tenant_id: + :vartype tenant_id: str + :ivar location_placement_id: + :vartype location_placement_id: str + :ivar quota_id: + :vartype quota_id: str + :ivar serialized_details: + :vartype serialized_details: str + :ivar registered_features: + :vartype registered_features: list[~azure.mgmt.databoxedge.v2020_09_01.models.SubscriptionRegisteredFeatures] """ _attribute_map = { - 'registration_id': {'key': 'registrationId', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'registration_date': {'key': 'registrationDate', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'location_placement_id': {'key': 'properties.locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'properties.quotaId', 'type': 'str'}, - 'serialized_details': {'key': 'properties.serializedDetails', 'type': 'str'}, - 'registered_features': {'key': 'properties.registeredFeatures', 'type': '[SubscriptionRegisteredFeatures]'}, + "registration_id": {"key": "registrationId", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "registration_date": {"key": "registrationDate", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "location_placement_id": {"key": "properties.locationPlacementId", "type": "str"}, + "quota_id": {"key": "properties.quotaId", "type": "str"}, + "serialized_details": {"key": "properties.serializedDetails", "type": "str"}, + "registered_features": {"key": "properties.registeredFeatures", "type": "[SubscriptionRegisteredFeatures]"}, } def __init__( self, *, registration_id: Optional[str] = None, - id: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + state: Optional[Union[str, "_models.SubscriptionState"]] = None, registration_date: Optional[str] = None, subscription_id: Optional[str] = None, tenant_id: Optional[str] = None, location_placement_id: Optional[str] = None, quota_id: Optional[str] = None, serialized_details: Optional[str] = None, - registered_features: Optional[List["SubscriptionRegisteredFeatures"]] = None, + registered_features: Optional[List["_models.SubscriptionRegisteredFeatures"]] = None, **kwargs ): - super(EdgeProfileSubscription, self).__init__(**kwargs) + """ + :keyword registration_id: Edge Subscription Registration ID. + :paramtype registration_id: str + :keyword id: ARM ID of the subscription. + :paramtype id: str + :keyword state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and + "Unregistered". + :paramtype state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SubscriptionState + :keyword registration_date: + :paramtype registration_date: str + :keyword subscription_id: + :paramtype subscription_id: str + :keyword tenant_id: + :paramtype tenant_id: str + :keyword location_placement_id: + :paramtype location_placement_id: str + :keyword quota_id: + :paramtype quota_id: str + :keyword serialized_details: + :paramtype serialized_details: str + :keyword registered_features: + :paramtype registered_features: + list[~azure.mgmt.databoxedge.v2020_09_01.models.SubscriptionRegisteredFeatures] + """ + super().__init__(**kwargs) self.registration_id = registration_id self.id = id self.state = state @@ -1628,28 +1748,27 @@ def __init__( self.registered_features = registered_features -class EdgeProfileSubscriptionPatch(msrest.serialization.Model): +class EdgeProfileSubscriptionPatch(_serialization.Model): """The Data Box Edge/Gateway Edge Profile Subscription patch. - :param id: The path ID that uniquely identifies the subscription of the edge profile. - :type id: str + :ivar id: The path ID that uniquely identifies the subscription of the edge profile. + :vartype id: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): - super(EdgeProfileSubscriptionPatch, self).__init__(**kwargs) + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The path ID that uniquely identifies the subscription of the edge profile. + :paramtype id: str + """ + super().__init__(**kwargs) self.id = id -class EtcdInfo(msrest.serialization.Model): +class EtcdInfo(_serialization.Model): """Etcd configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1661,20 +1780,18 @@ class EtcdInfo(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(EtcdInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None @@ -1682,8 +1799,8 @@ def __init__( class Trigger(ARMBaseModel): """Trigger details. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FileEventTrigger, PeriodicTimerEventTrigger Variables are only populated by the server, and will be ignored when sending a request. @@ -1697,38 +1814,33 @@ class Trigger(ARMBaseModel): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.TriggerEventType + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.TriggerEventType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } + _subtype_map = {"kind": {"FileEvent": "FileEventTrigger", "PeriodicTimerEvent": "PeriodicTimerEventTrigger"}} - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None - self.kind = 'Trigger' # type: str + self.kind: Optional[str] = None class FileEventTrigger(Trigger): @@ -1746,100 +1858,108 @@ class FileEventTrigger(Trigger): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2020_09_01.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2020_09_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.TriggerEventType + :ivar source_info: File event source details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2020_09_01.models.FileSourceInfo + :ivar sink_info: Role sink info. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2020_09_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "FileSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "FileSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.FileSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str + """ + :keyword source_info: File event source details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2020_09_01.models.FileSourceInfo + :keyword sink_info: Role sink info. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2020_09_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "FileEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class FileSourceInfo(msrest.serialization.Model): +class FileSourceInfo(_serialization.Model): """File source details. All required parameters must be populated in order to send to Azure. - :param share_id: Required. File share ID. - :type share_id: str + :ivar share_id: File share ID. Required. + :vartype share_id: str """ _validation = { - 'share_id': {'required': True}, + "share_id": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: File share ID. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id -class GenerateCertResponse(msrest.serialization.Model): +class GenerateCertResponse(_serialization.Model): """Used in activation key generation flow. - :param public_key: Gets or sets base64 encoded certificate raw data, + :ivar public_key: Gets or sets base64 encoded certificate raw data, this is the public part needed to be uploaded to cert vault. - :type public_key: str - :param private_key: Gets or sets base64 encoded private part of the certificate, + :vartype public_key: str + :ivar private_key: Gets or sets base64 encoded private part of the certificate, needed to form the activation key. - :type private_key: str - :param expiry_time_in_utc: Gets or sets expiry time in UTC. - :type expiry_time_in_utc: str + :vartype private_key: str + :ivar expiry_time_in_utc: Gets or sets expiry time in UTC. + :vartype expiry_time_in_utc: str """ _attribute_map = { - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'expiry_time_in_utc': {'key': 'expiryTimeInUTC', 'type': 'str'}, + "public_key": {"key": "publicKey", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "expiry_time_in_utc": {"key": "expiryTimeInUTC", "type": "str"}, } def __init__( @@ -1850,34 +1970,44 @@ def __init__( expiry_time_in_utc: Optional[str] = None, **kwargs ): - super(GenerateCertResponse, self).__init__(**kwargs) + """ + :keyword public_key: Gets or sets base64 encoded certificate raw data, + this is the public part needed to be uploaded to cert vault. + :paramtype public_key: str + :keyword private_key: Gets or sets base64 encoded private part of the certificate, + needed to form the activation key. + :paramtype private_key: str + :keyword expiry_time_in_utc: Gets or sets expiry time in UTC. + :paramtype expiry_time_in_utc: str + """ + super().__init__(**kwargs) self.public_key = public_key self.private_key = private_key self.expiry_time_in_utc = expiry_time_in_utc -class ImageRepositoryCredential(msrest.serialization.Model): +class ImageRepositoryCredential(_serialization.Model): """Image repository credential. All required parameters must be populated in order to send to Azure. - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + :ivar image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :vartype image_repository_url: str + :ivar user_name: Repository user name. Required. + :vartype user_name: str + :ivar password: Repository user password. + :vartype password: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret """ _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, + "image_repository_url": {"required": True}, + "user_name": {"required": True}, } _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, + "image_repository_url": {"key": "imageRepositoryUrl", "type": "str"}, + "user_name": {"key": "userName", "type": "str"}, + "password": {"key": "password", "type": "AsymmetricEncryptedSecret"}, } def __init__( @@ -1885,16 +2015,24 @@ def __init__( *, image_repository_url: str, user_name: str, - password: Optional["AsymmetricEncryptedSecret"] = None, + password: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs ): - super(ImageRepositoryCredential, self).__init__(**kwargs) + """ + :keyword image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :paramtype image_repository_url: str + :keyword user_name: Repository user name. Required. + :paramtype user_name: str + :keyword password: Repository user password. + :paramtype password: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.image_repository_url = image_repository_url self.user_name = user_name self.password = password -class IoTAddon(Addon): +class IoTAddon(Addon): # pylint: disable=too-many-instance-attributes """IoT Addon. Variables are only populated by the server, and will be ignored when sending a request. @@ -1907,67 +2045,74 @@ class IoTAddon(Addon): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param io_t_device_details: Required. IoT device metadata to which appliance needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo - :param io_t_edge_device_details: Required. IoT edge device to which the IoT Addon needs to be - configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo + :ivar io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be configured. + Required. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo :ivar version: Version of IoT running on the appliance. :vartype version: str - :ivar host_platform: Host OS supported by the IoT addon. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the IoT addon. Known values are: "Windows" and "Linux". :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AddonState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'io_t_device_details': {'required': True}, - 'io_t_edge_device_details': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "io_t_device_details": {"required": True}, + "io_t_edge_device_details": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - io_t_device_details: "IoTDeviceInfo", - io_t_edge_device_details: "IoTDeviceInfo", + io_t_device_details: "_models.IoTDeviceInfo", + io_t_edge_device_details: "_models.IoTDeviceInfo", **kwargs ): - super(IoTAddon, self).__init__(**kwargs) - self.kind = 'IotEdge' # type: str + """ + :keyword io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :paramtype io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be + configured. Required. + :paramtype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo + """ + super().__init__(**kwargs) + self.kind: str = "IotEdge" self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details self.version = None @@ -1976,31 +2121,31 @@ def __init__( self.provisioning_state = None -class IoTDeviceInfo(msrest.serialization.Model): +class IoTDeviceInfo(_serialization.Model): """Metadata of IoT device/IoT Edge device to be configured. All required parameters must be populated in order to send to Azure. - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2020_09_01.models.Authentication + :ivar device_id: ID of the IoT device/edge device. Required. + :vartype device_id: str + :ivar io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :vartype io_t_host_hub: str + :ivar io_t_host_hub_id: Id for the IoT hub associated to the device. + :vartype io_t_host_hub_id: str + :ivar authentication: Encrypted IoT device/IoT edge device connection string. + :vartype authentication: ~azure.mgmt.databoxedge.v2020_09_01.models.Authentication """ _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, + "device_id": {"required": True}, + "io_t_host_hub": {"required": True}, } _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, + "device_id": {"key": "deviceId", "type": "str"}, + "io_t_host_hub": {"key": "ioTHostHub", "type": "str"}, + "io_t_host_hub_id": {"key": "ioTHostHubId", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, } def __init__( @@ -2009,38 +2154,48 @@ def __init__( device_id: str, io_t_host_hub: str, io_t_host_hub_id: Optional[str] = None, - authentication: Optional["Authentication"] = None, + authentication: Optional["_models.Authentication"] = None, **kwargs ): - super(IoTDeviceInfo, self).__init__(**kwargs) + """ + :keyword device_id: ID of the IoT device/edge device. Required. + :paramtype device_id: str + :keyword io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :paramtype io_t_host_hub: str + :keyword io_t_host_hub_id: Id for the IoT hub associated to the device. + :paramtype io_t_host_hub_id: str + :keyword authentication: Encrypted IoT device/IoT edge device connection string. + :paramtype authentication: ~azure.mgmt.databoxedge.v2020_09_01.models.Authentication + """ + super().__init__(**kwargs) self.device_id = device_id self.io_t_host_hub = io_t_host_hub self.io_t_host_hub_id = io_t_host_hub_id self.authentication = authentication -class IoTEdgeAgentInfo(msrest.serialization.Model): +class IoTEdgeAgentInfo(_serialization.Model): """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. All required parameters must be populated in order to send to Azure. - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: ~azure.mgmt.databoxedge.v2020_09_01.models.ImageRepositoryCredential + :ivar image_name: Name of the IoT edge agent image. Required. + :vartype image_name: str + :ivar tag: Image Tag. Required. + :vartype tag: str + :ivar image_repository: Image repository details. + :vartype image_repository: ~azure.mgmt.databoxedge.v2020_09_01.models.ImageRepositoryCredential """ _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, + "image_name": {"required": True}, + "tag": {"required": True}, } _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, + "image_name": {"key": "imageName", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "image_repository": {"key": "imageRepository", "type": "ImageRepositoryCredential"}, } def __init__( @@ -2048,16 +2203,25 @@ def __init__( *, image_name: str, tag: str, - image_repository: Optional["ImageRepositoryCredential"] = None, + image_repository: Optional["_models.ImageRepositoryCredential"] = None, **kwargs ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) + """ + :keyword image_name: Name of the IoT edge agent image. Required. + :paramtype image_name: str + :keyword tag: Image Tag. Required. + :paramtype tag: str + :keyword image_repository: Image repository details. + :paramtype image_repository: + ~azure.mgmt.databoxedge.v2020_09_01.models.ImageRepositoryCredential + """ + super().__init__(**kwargs) self.image_name = image_name self.tag = tag self.image_repository = image_repository -class IoTRole(Role): +class IoTRole(Role): # pylint: disable=too-many-instance-attributes """Compute role. Variables are only populated by the server, and will be ignored when sending a request. @@ -2070,72 +2234,92 @@ class IoTRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the IoT role. Known values are: "Windows" and "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType + :ivar io_t_device_details: IoT device metadata to which data box edge device needs to be connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo + :ivar share_mappings: Mount points of shares in role(s). + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] + :ivar io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :vartype io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTEdgeAgentInfo + :ivar host_platform_type: Platform where the Iot runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.HostPlatformType - :param compute_resource: Resource allocation. - :type compute_resource: ~azure.mgmt.databoxedge.v2020_09_01.models.ComputeResource - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus + :ivar compute_resource: Resource allocation. + :vartype compute_resource: ~azure.mgmt.databoxedge.v2020_09_01.models.ComputeResource + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'host_platform_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "host_platform_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'compute_resource': {'key': 'properties.computeResource', 'type': 'ComputeResource'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "io_t_edge_agent_info": {"key": "properties.ioTEdgeAgentInfo", "type": "IoTEdgeAgentInfo"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "compute_resource": {"key": "properties.computeResource", "type": "ComputeResource"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - io_t_device_details: Optional["IoTDeviceInfo"] = None, - io_t_edge_device_details: Optional["IoTDeviceInfo"] = None, - share_mappings: Optional[List["MountPointMap"]] = None, - io_t_edge_agent_info: Optional["IoTEdgeAgentInfo"] = None, - compute_resource: Optional["ComputeResource"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + io_t_device_details: Optional["_models.IoTDeviceInfo"] = None, + io_t_edge_device_details: Optional["_models.IoTDeviceInfo"] = None, + share_mappings: Optional[List["_models.MountPointMap"]] = None, + io_t_edge_agent_info: Optional["_models.IoTEdgeAgentInfo"] = None, + compute_resource: Optional["_models.ComputeResource"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str + """ + :keyword host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :paramtype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType + :keyword io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :paramtype io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT role needs to be + configured. + :paramtype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTDeviceInfo + :keyword share_mappings: Mount points of shares in role(s). + :paramtype share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] + :keyword io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + runtime. + :paramtype io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_09_01.models.IoTEdgeAgentInfo + :keyword compute_resource: Resource allocation. + :paramtype compute_resource: ~azure.mgmt.databoxedge.v2020_09_01.models.ComputeResource + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "IOT" self.host_platform = host_platform self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details @@ -2146,7 +2330,7 @@ def __init__( self.role_status = role_status -class Ipv4Config(msrest.serialization.Model): +class Ipv4Config(_serialization.Model): """Details related to the IPv4 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2160,28 +2344,26 @@ class Ipv4Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "subnet": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.subnet = None self.gateway = None -class Ipv6Config(msrest.serialization.Model): +class Ipv6Config(_serialization.Model): """Details related to the IPv6 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2195,28 +2377,26 @@ class Ipv6Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "prefix_length": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "int"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.prefix_length = None self.gateway = None -class Job(msrest.serialization.Model): +class Job(_serialization.Model): # pylint: disable=too-many-instance-attributes """A device job. Variables are only populated by the server, and will be ignored when sending a request. @@ -2227,8 +2407,8 @@ class Job(msrest.serialization.Model): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar status: The current status of the job. Known values are: "Invalid", "Running", + "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.JobStatus :ivar start_time: The UTC date and time at which the job started. :vartype start_time: ~datetime.datetime @@ -2238,14 +2418,14 @@ class Job(msrest.serialization.Model): :vartype percent_complete: int :ivar error: The error details. :vartype error: ~azure.mgmt.databoxedge.v2020_09_01.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", + :ivar job_type: The type of the job. Known values are: "Invalid", "ScanForUpdates", "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer", "Backup", "Restore", - "TriggerSupportPackage". + and "TriggerSupportPackage". :vartype job_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", + :ivar current_stage: Current stage of the update operation. Known values are: "Unknown", "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". + "Success", "Failure", "RescanStarted", "RescanComplete", and "RescanFailed". :vartype current_stage: str or ~azure.mgmt.databoxedge.v2020_09_01.models.UpdateOperationStage :ivar download_progress: The download progress. :vartype download_progress: ~azure.mgmt.databoxedge.v2020_09_01.models.UpdateDownloadProgress @@ -2258,55 +2438,55 @@ class Job(msrest.serialization.Model): :vartype error_manifest_file: str :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str + :ivar folder: If only subfolders need to be refreshed, then the subfolder path inside the share + or container. (The path is empty if there are no subfolders.). + :vartype folder: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "error": {"readonly": True}, + "job_type": {"readonly": True}, + "current_stage": {"readonly": True}, + "download_progress": {"readonly": True}, + "install_progress": {"readonly": True}, + "total_refresh_errors": {"readonly": True}, + "error_manifest_file": {"readonly": True}, + "refreshed_entity_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - *, - folder: Optional[str] = None, - **kwargs - ): - super(Job, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "error": {"key": "error", "type": "JobErrorDetails"}, + "job_type": {"key": "properties.jobType", "type": "str"}, + "current_stage": {"key": "properties.currentStage", "type": "str"}, + "download_progress": {"key": "properties.downloadProgress", "type": "UpdateDownloadProgress"}, + "install_progress": {"key": "properties.installProgress", "type": "UpdateInstallProgress"}, + "total_refresh_errors": {"key": "properties.totalRefreshErrors", "type": "int"}, + "error_manifest_file": {"key": "properties.errorManifestFile", "type": "str"}, + "refreshed_entity_id": {"key": "properties.refreshedEntityId", "type": "str"}, + "folder": {"key": "properties.folder", "type": "str"}, + } + + def __init__(self, *, folder: Optional[str] = None, **kwargs): + """ + :keyword folder: If only subfolders need to be refreshed, then the subfolder path inside the + share or container. (The path is empty if there are no subfolders.). + :paramtype folder: str + """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2325,7 +2505,7 @@ def __init__( self.folder = folder -class JobErrorDetails(msrest.serialization.Model): +class JobErrorDetails(_serialization.Model): """The job error information containing the list of job errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -2339,28 +2519,26 @@ class JobErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "error_details": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "error_details": {"key": "errorDetails", "type": "[JobErrorItem]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_details = None self.code = None self.message = None -class JobErrorItem(msrest.serialization.Model): +class JobErrorItem(_serialization.Model): """The job error items. Variables are only populated by the server, and will be ignored when sending a request. @@ -2374,28 +2552,26 @@ class JobErrorItem(msrest.serialization.Model): """ _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "recommendations": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "recommendations": {"key": "recommendations", "type": "[str]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.recommendations = None self.code = None self.message = None -class KubernetesClusterInfo(msrest.serialization.Model): +class KubernetesClusterInfo(_serialization.Model): """Kubernetes cluster configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2406,66 +2582,64 @@ class KubernetesClusterInfo(msrest.serialization.Model): :vartype etcd_info: ~azure.mgmt.databoxedge.v2020_09_01.models.EtcdInfo :ivar nodes: Kubernetes cluster nodes. :vartype nodes: list[~azure.mgmt.databoxedge.v2020_09_01.models.NodeInfo] - :param version: Required. Kubernetes cluster version. - :type version: str + :ivar version: Kubernetes cluster version. Required. + :vartype version: str """ _validation = { - 'etcd_info': {'readonly': True}, - 'nodes': {'readonly': True}, - 'version': {'required': True}, + "etcd_info": {"readonly": True}, + "nodes": {"readonly": True}, + "version": {"required": True}, } _attribute_map = { - 'etcd_info': {'key': 'etcdInfo', 'type': 'EtcdInfo'}, - 'nodes': {'key': 'nodes', 'type': '[NodeInfo]'}, - 'version': {'key': 'version', 'type': 'str'}, + "etcd_info": {"key": "etcdInfo", "type": "EtcdInfo"}, + "nodes": {"key": "nodes", "type": "[NodeInfo]"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - *, - version: str, - **kwargs - ): - super(KubernetesClusterInfo, self).__init__(**kwargs) + def __init__(self, *, version: str, **kwargs): + """ + :keyword version: Kubernetes cluster version. Required. + :paramtype version: str + """ + super().__init__(**kwargs) self.etcd_info = None self.nodes = None self.version = version -class KubernetesIPConfiguration(msrest.serialization.Model): +class KubernetesIPConfiguration(_serialization.Model): """Kubernetes node IP configuration. Variables are only populated by the server, and will be ignored when sending a request. :ivar port: Port of the Kubernetes node. :vartype port: str - :param ip_address: IP address of the Kubernetes node. - :type ip_address: str + :ivar ip_address: IP address of the Kubernetes node. + :vartype ip_address: str """ _validation = { - 'port': {'readonly': True}, + "port": {"readonly": True}, } _attribute_map = { - 'port': {'key': 'port', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + "port": {"key": "port", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, } - def __init__( - self, - *, - ip_address: Optional[str] = None, - **kwargs - ): - super(KubernetesIPConfiguration, self).__init__(**kwargs) + def __init__(self, *, ip_address: Optional[str] = None, **kwargs): + """ + :keyword ip_address: IP address of the Kubernetes node. + :paramtype ip_address: str + """ + super().__init__(**kwargs) self.port = None self.ip_address = ip_address -class KubernetesRole(Role): +class KubernetesRole(Role): # pylint: disable=too-many-instance-attributes """Kubernetes role. Variables are only populated by the server, and will be ignored when sending a request. @@ -2478,64 +2652,78 @@ class KubernetesRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param host_platform: Host OS supported by the Kubernetes role. Possible values include: - "Windows", "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType - :ivar provisioning_state: State of Kubernetes deployment. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" and + "Linux". + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType + :ivar provisioning_state: State of Kubernetes deployment. Known values are: "Invalid", + "Creating", "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesState - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.HostPlatformType - :param kubernetes_cluster_info: Kubernetes cluster configuration. - :type kubernetes_cluster_info: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesClusterInfo - :param kubernetes_role_resources: Kubernetes role resources. - :type kubernetes_role_resources: + :ivar kubernetes_cluster_info: Kubernetes cluster configuration. + :vartype kubernetes_cluster_info: + ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesClusterInfo + :ivar kubernetes_role_resources: Kubernetes role resources. + :vartype kubernetes_role_resources: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleResources - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'host_platform_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "host_platform_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'kubernetes_cluster_info': {'key': 'properties.kubernetesClusterInfo', 'type': 'KubernetesClusterInfo'}, - 'kubernetes_role_resources': {'key': 'properties.kubernetesRoleResources', 'type': 'KubernetesRoleResources'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "kubernetes_cluster_info": {"key": "properties.kubernetesClusterInfo", "type": "KubernetesClusterInfo"}, + "kubernetes_role_resources": {"key": "properties.kubernetesRoleResources", "type": "KubernetesRoleResources"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - kubernetes_cluster_info: Optional["KubernetesClusterInfo"] = None, - kubernetes_role_resources: Optional["KubernetesRoleResources"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + kubernetes_cluster_info: Optional["_models.KubernetesClusterInfo"] = None, + kubernetes_role_resources: Optional["_models.KubernetesRoleResources"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(KubernetesRole, self).__init__(**kwargs) - self.kind = 'Kubernetes' # type: str + """ + :keyword host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" + and "Linux". + :paramtype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PlatformType + :keyword kubernetes_cluster_info: Kubernetes cluster configuration. + :paramtype kubernetes_cluster_info: + ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesClusterInfo + :keyword kubernetes_role_resources: Kubernetes role resources. + :paramtype kubernetes_role_resources: + ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleResources + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "Kubernetes" self.host_platform = host_platform self.provisioning_state = None self.host_platform_type = None @@ -2544,46 +2732,45 @@ def __init__( self.role_status = role_status -class KubernetesRoleCompute(msrest.serialization.Model): +class KubernetesRoleCompute(_serialization.Model): """Kubernetes role compute resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param vm_profile: Required. VM profile. - :type vm_profile: str + :ivar vm_profile: VM profile. Required. + :vartype vm_profile: str :ivar memory_in_bytes: Memory in bytes. - :vartype memory_in_bytes: long + :vartype memory_in_bytes: int :ivar processor_count: Processor count. :vartype processor_count: int """ _validation = { - 'vm_profile': {'required': True}, - 'memory_in_bytes': {'readonly': True}, - 'processor_count': {'readonly': True}, + "vm_profile": {"required": True}, + "memory_in_bytes": {"readonly": True}, + "processor_count": {"readonly": True}, } _attribute_map = { - 'vm_profile': {'key': 'vmProfile', 'type': 'str'}, - 'memory_in_bytes': {'key': 'memoryInBytes', 'type': 'long'}, - 'processor_count': {'key': 'processorCount', 'type': 'int'}, + "vm_profile": {"key": "vmProfile", "type": "str"}, + "memory_in_bytes": {"key": "memoryInBytes", "type": "int"}, + "processor_count": {"key": "processorCount", "type": "int"}, } - def __init__( - self, - *, - vm_profile: str, - **kwargs - ): - super(KubernetesRoleCompute, self).__init__(**kwargs) + def __init__(self, *, vm_profile: str, **kwargs): + """ + :keyword vm_profile: VM profile. Required. + :paramtype vm_profile: str + """ + super().__init__(**kwargs) self.vm_profile = vm_profile self.memory_in_bytes = None self.processor_count = None -class KubernetesRoleNetwork(msrest.serialization.Model): +class KubernetesRoleNetwork(_serialization.Model): """Kubernetes role network resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2595,64 +2782,68 @@ class KubernetesRoleNetwork(msrest.serialization.Model): """ _validation = { - 'cni_config': {'readonly': True}, - 'load_balancer_config': {'readonly': True}, + "cni_config": {"readonly": True}, + "load_balancer_config": {"readonly": True}, } _attribute_map = { - 'cni_config': {'key': 'cniConfig', 'type': 'CniConfig'}, - 'load_balancer_config': {'key': 'loadBalancerConfig', 'type': 'LoadBalancerConfig'}, + "cni_config": {"key": "cniConfig", "type": "CniConfig"}, + "load_balancer_config": {"key": "loadBalancerConfig", "type": "LoadBalancerConfig"}, } - def __init__( - self, - **kwargs - ): - super(KubernetesRoleNetwork, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cni_config = None self.load_balancer_config = None -class KubernetesRoleResources(msrest.serialization.Model): +class KubernetesRoleResources(_serialization.Model): """Kubernetes role resources. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param storage: Kubernetes role storage resource. - :type storage: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleStorage - :param compute: Required. Kubernetes role compute resource. - :type compute: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleCompute + :ivar storage: Kubernetes role storage resource. + :vartype storage: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleStorage + :ivar compute: Kubernetes role compute resource. Required. + :vartype compute: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleCompute :ivar network: Kubernetes role network resource. :vartype network: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleNetwork """ _validation = { - 'compute': {'required': True}, - 'network': {'readonly': True}, + "compute": {"required": True}, + "network": {"readonly": True}, } _attribute_map = { - 'storage': {'key': 'storage', 'type': 'KubernetesRoleStorage'}, - 'compute': {'key': 'compute', 'type': 'KubernetesRoleCompute'}, - 'network': {'key': 'network', 'type': 'KubernetesRoleNetwork'}, + "storage": {"key": "storage", "type": "KubernetesRoleStorage"}, + "compute": {"key": "compute", "type": "KubernetesRoleCompute"}, + "network": {"key": "network", "type": "KubernetesRoleNetwork"}, } def __init__( self, *, - compute: "KubernetesRoleCompute", - storage: Optional["KubernetesRoleStorage"] = None, + compute: "_models.KubernetesRoleCompute", + storage: Optional["_models.KubernetesRoleStorage"] = None, **kwargs ): - super(KubernetesRoleResources, self).__init__(**kwargs) + """ + :keyword storage: Kubernetes role storage resource. + :paramtype storage: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleStorage + :keyword compute: Kubernetes role compute resource. Required. + :paramtype compute: ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleCompute + """ + super().__init__(**kwargs) self.storage = storage self.compute = compute self.network = None -class KubernetesRoleStorage(msrest.serialization.Model): +class KubernetesRoleStorage(_serialization.Model): """Kubernetes role storage resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2660,31 +2851,30 @@ class KubernetesRoleStorage(msrest.serialization.Model): :ivar storage_classes: Kubernetes storage class info. :vartype storage_classes: list[~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesRoleStorageClassInfo] - :param endpoints: Mount points of shares in role(s). - :type endpoints: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] + :ivar endpoints: Mount points of shares in role(s). + :vartype endpoints: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] """ _validation = { - 'storage_classes': {'readonly': True}, + "storage_classes": {"readonly": True}, } _attribute_map = { - 'storage_classes': {'key': 'storageClasses', 'type': '[KubernetesRoleStorageClassInfo]'}, - 'endpoints': {'key': 'endpoints', 'type': '[MountPointMap]'}, + "storage_classes": {"key": "storageClasses", "type": "[KubernetesRoleStorageClassInfo]"}, + "endpoints": {"key": "endpoints", "type": "[MountPointMap]"}, } - def __init__( - self, - *, - endpoints: Optional[List["MountPointMap"]] = None, - **kwargs - ): - super(KubernetesRoleStorage, self).__init__(**kwargs) + def __init__(self, *, endpoints: Optional[List["_models.MountPointMap"]] = None, **kwargs): + """ + :keyword endpoints: Mount points of shares in role(s). + :paramtype endpoints: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] + """ + super().__init__(**kwargs) self.storage_classes = None self.endpoints = endpoints -class KubernetesRoleStorageClassInfo(msrest.serialization.Model): +class KubernetesRoleStorageClassInfo(_serialization.Model): """Kubernetes storage class info. Variables are only populated by the server, and will be ignored when sending a request. @@ -2693,35 +2883,33 @@ class KubernetesRoleStorageClassInfo(msrest.serialization.Model): :vartype name: str :ivar type: Storage class type. :vartype type: str - :ivar posix_compliant: If provisioned storage is posix compliant. Possible values include: - "Invalid", "Enabled", "Disabled". + :ivar posix_compliant: If provisioned storage is posix compliant. Known values are: "Invalid", + "Enabled", and "Disabled". :vartype posix_compliant: str or ~azure.mgmt.databoxedge.v2020_09_01.models.PosixComplianceStatus """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'posix_compliant': {'readonly': True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "posix_compliant": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'posix_compliant': {'key': 'posixCompliant', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "posix_compliant": {"key": "posixCompliant", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorageClassInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.type = None self.posix_compliant = None -class LoadBalancerConfig(msrest.serialization.Model): +class LoadBalancerConfig(_serialization.Model): """Load balancer configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2733,20 +2921,18 @@ class LoadBalancerConfig(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(LoadBalancerConfig, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None @@ -2764,116 +2950,136 @@ class MECRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param connection_string: Activation key of the MEC. - :type connection_string: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus + :ivar connection_string: Activation key of the MEC. + :vartype connection_string: + ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'AsymmetricEncryptedSecret'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "connection_string": {"key": "properties.connectionString", "type": "AsymmetricEncryptedSecret"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(MECRole, self).__init__(**kwargs) - self.kind = 'MEC' # type: str + """ + :keyword connection_string: Activation key of the MEC. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "MEC" self.connection_string = connection_string self.role_status = role_status -class MetricConfiguration(msrest.serialization.Model): +class MetricConfiguration(_serialization.Model): """Metric configuration. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. The Resource ID on which the metrics should be pushed. - :type resource_id: str - :param mdm_account: The MDM account to which the counters should be pushed. - :type mdm_account: str - :param metric_name_space: The MDM namespace to which the counters should be pushed. This is + :ivar resource_id: The Resource ID on which the metrics should be pushed. Required. + :vartype resource_id: str + :ivar mdm_account: The MDM account to which the counters should be pushed. + :vartype mdm_account: str + :ivar metric_name_space: The MDM namespace to which the counters should be pushed. This is required if MDMAccount is specified. - :type metric_name_space: str - :param counter_sets: Required. Host name for the IoT hub associated to the device. - :type counter_sets: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricCounterSet] + :vartype metric_name_space: str + :ivar counter_sets: Host name for the IoT hub associated to the device. Required. + :vartype counter_sets: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricCounterSet] """ _validation = { - 'resource_id': {'required': True}, - 'counter_sets': {'required': True}, + "resource_id": {"required": True}, + "counter_sets": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'mdm_account': {'key': 'mdmAccount', 'type': 'str'}, - 'metric_name_space': {'key': 'metricNameSpace', 'type': 'str'}, - 'counter_sets': {'key': 'counterSets', 'type': '[MetricCounterSet]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "mdm_account": {"key": "mdmAccount", "type": "str"}, + "metric_name_space": {"key": "metricNameSpace", "type": "str"}, + "counter_sets": {"key": "counterSets", "type": "[MetricCounterSet]"}, } def __init__( self, *, resource_id: str, - counter_sets: List["MetricCounterSet"], + counter_sets: List["_models.MetricCounterSet"], mdm_account: Optional[str] = None, metric_name_space: Optional[str] = None, **kwargs ): - super(MetricConfiguration, self).__init__(**kwargs) + """ + :keyword resource_id: The Resource ID on which the metrics should be pushed. Required. + :paramtype resource_id: str + :keyword mdm_account: The MDM account to which the counters should be pushed. + :paramtype mdm_account: str + :keyword metric_name_space: The MDM namespace to which the counters should be pushed. This is + required if MDMAccount is specified. + :paramtype metric_name_space: str + :keyword counter_sets: Host name for the IoT hub associated to the device. Required. + :paramtype counter_sets: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricCounterSet] + """ + super().__init__(**kwargs) self.resource_id = resource_id self.mdm_account = mdm_account self.metric_name_space = metric_name_space self.counter_sets = counter_sets -class MetricCounter(msrest.serialization.Model): +class MetricCounter(_serialization.Model): """The metric counter. All required parameters must be populated in order to send to Azure. - :param name: Required. The counter name. - :type name: str - :param instance: The instance from which counter should be collected. - :type instance: str - :param dimension_filter: The dimension filter. - :type dimension_filter: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimension] - :param additional_dimensions: The additional dimensions to be added to metric. - :type additional_dimensions: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimension] + :ivar name: The counter name. Required. + :vartype name: str + :ivar instance: The instance from which counter should be collected. + :vartype instance: str + :ivar dimension_filter: The dimension filter. + :vartype dimension_filter: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimension] + :ivar additional_dimensions: The additional dimensions to be added to metric. + :vartype additional_dimensions: + list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimension] """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, - 'dimension_filter': {'key': 'dimensionFilter', 'type': '[MetricDimension]'}, - 'additional_dimensions': {'key': 'additionalDimensions', 'type': '[MetricDimension]'}, + "name": {"key": "name", "type": "str"}, + "instance": {"key": "instance", "type": "str"}, + "dimension_filter": {"key": "dimensionFilter", "type": "[MetricDimension]"}, + "additional_dimensions": {"key": "additionalDimensions", "type": "[MetricDimension]"}, } def __init__( @@ -2881,92 +3087,102 @@ def __init__( *, name: str, instance: Optional[str] = None, - dimension_filter: Optional[List["MetricDimension"]] = None, - additional_dimensions: Optional[List["MetricDimension"]] = None, + dimension_filter: Optional[List["_models.MetricDimension"]] = None, + additional_dimensions: Optional[List["_models.MetricDimension"]] = None, **kwargs ): - super(MetricCounter, self).__init__(**kwargs) + """ + :keyword name: The counter name. Required. + :paramtype name: str + :keyword instance: The instance from which counter should be collected. + :paramtype instance: str + :keyword dimension_filter: The dimension filter. + :paramtype dimension_filter: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimension] + :keyword additional_dimensions: The additional dimensions to be added to metric. + :paramtype additional_dimensions: + list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimension] + """ + super().__init__(**kwargs) self.name = name self.instance = instance self.dimension_filter = dimension_filter self.additional_dimensions = additional_dimensions -class MetricCounterSet(msrest.serialization.Model): +class MetricCounterSet(_serialization.Model): """The metric counter set. All required parameters must be populated in order to send to Azure. - :param counters: Required. The counters that should be collected in this set. - :type counters: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricCounter] + :ivar counters: The counters that should be collected in this set. Required. + :vartype counters: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricCounter] """ _validation = { - 'counters': {'required': True}, + "counters": {"required": True}, } _attribute_map = { - 'counters': {'key': 'counters', 'type': '[MetricCounter]'}, + "counters": {"key": "counters", "type": "[MetricCounter]"}, } - def __init__( - self, - *, - counters: List["MetricCounter"], - **kwargs - ): - super(MetricCounterSet, self).__init__(**kwargs) + def __init__(self, *, counters: List["_models.MetricCounter"], **kwargs): + """ + :keyword counters: The counters that should be collected in this set. Required. + :paramtype counters: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricCounter] + """ + super().__init__(**kwargs) self.counters = counters -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """The metric dimension. All required parameters must be populated in order to send to Azure. - :param source_type: Required. The dimension type. - :type source_type: str - :param source_name: Required. The dimension value. - :type source_name: str + :ivar source_type: The dimension type. Required. + :vartype source_type: str + :ivar source_name: The dimension value. Required. + :vartype source_name: str """ _validation = { - 'source_type': {'required': True}, - 'source_name': {'required': True}, + "source_type": {"required": True}, + "source_name": {"required": True}, } _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'source_name': {'key': 'sourceName', 'type': 'str'}, - } - - def __init__( - self, - *, - source_type: str, - source_name: str, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) + "source_type": {"key": "sourceType", "type": "str"}, + "source_name": {"key": "sourceName", "type": "str"}, + } + + def __init__(self, *, source_type: str, source_name: str, **kwargs): + """ + :keyword source_type: The dimension type. Required. + :paramtype source_type: str + :keyword source_name: The dimension value. Required. + :paramtype source_name: str + """ + super().__init__(**kwargs) self.source_type = source_type self.source_name = source_name -class MetricDimensionV1(msrest.serialization.Model): +class MetricDimensionV1(_serialization.Model): """Metric Dimension v1. - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the metrics dimension. + :vartype name: str + :ivar display_name: Display name of the metrics dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -2977,55 +3193,64 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(MetricDimensionV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metrics dimension. + :paramtype name: str + :keyword display_name: Display name of the metrics dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecificationV1(msrest.serialization.Model): +class MetricSpecificationV1(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric specification version 1. - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Description of the metric to be displayed. + :vartype display_description: str + :ivar unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :vartype unit: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricUnit + :ivar aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :vartype aggregation_type: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.MetricAggregationType + :ivar dimensions: Metric dimensions, other than default dimension which is resource. + :vartype dimensions: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimensionV1] + :ivar fill_gap_with_zero: Set true to fill the gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar category: Metric category. Known values are: "Capacity" and "Transaction". + :vartype category: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricCategory + :ivar resource_id_dimension_name_override: Resource name override. + :vartype resource_id_dimension_name_override: str + :ivar supported_time_grain_types: Support granularity of metrics. + :vartype supported_time_grain_types: list[str or ~azure.mgmt.databoxedge.v2020_09_01.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricAggregationType] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimensionV1]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, } def __init__( @@ -3034,17 +3259,46 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, display_description: Optional[str] = None, - unit: Optional[Union[str, "MetricUnit"]] = None, - aggregation_type: Optional[Union[str, "MetricAggregationType"]] = None, - dimensions: Optional[List["MetricDimensionV1"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, + dimensions: Optional[List["_models.MetricDimensionV1"]] = None, fill_gap_with_zero: Optional[bool] = None, - category: Optional[Union[str, "MetricCategory"]] = None, + category: Optional[Union[str, "_models.MetricCategory"]] = None, resource_id_dimension_name_override: Optional[str] = None, - supported_time_grain_types: Optional[List[Union[str, "TimeGrain"]]] = None, - supported_aggregation_types: Optional[List[Union[str, "MetricAggregationType"]]] = None, + supported_time_grain_types: Optional[List[Union[str, "_models.TimeGrain"]]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, **kwargs ): - super(MetricSpecificationV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Description of the metric to be displayed. + :paramtype display_description: str + :keyword unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :paramtype unit: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricUnit + :keyword aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :paramtype aggregation_type: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.MetricAggregationType + :keyword dimensions: Metric dimensions, other than default dimension which is resource. + :paramtype dimensions: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricDimensionV1] + :keyword fill_gap_with_zero: Set true to fill the gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: Metric category. Known values are: "Capacity" and "Transaction". + :paramtype category: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MetricCategory + :keyword resource_id_dimension_name_override: Resource name override. + :paramtype resource_id_dimension_name_override: str + :keyword supported_time_grain_types: Support granularity of metrics. + :paramtype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2020_09_01.models.TimeGrain] + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2020_09_01.models.MetricAggregationType] + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -3071,36 +3325,36 @@ class MonitoringMetricConfiguration(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param metric_configurations: Required. The metrics configuration details. - :type metric_configurations: + :ivar metric_configurations: The metrics configuration details. Required. + :vartype metric_configurations: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricConfiguration] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'metric_configurations': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "metric_configurations": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metric_configurations': {'key': 'properties.metricConfigurations', 'type': '[MetricConfiguration]'}, - } - - def __init__( - self, - *, - metric_configurations: List["MetricConfiguration"], - **kwargs - ): - super(MonitoringMetricConfiguration, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metric_configurations": {"key": "properties.metricConfigurations", "type": "[MetricConfiguration]"}, + } + + def __init__(self, *, metric_configurations: List["_models.MetricConfiguration"], **kwargs): + """ + :keyword metric_configurations: The metrics configuration details. Required. + :paramtype metric_configurations: + list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricConfiguration] + """ + super().__init__(**kwargs) self.metric_configurations = metric_configurations -class MonitoringMetricConfigurationList(msrest.serialization.Model): +class MonitoringMetricConfigurationList(_serialization.Model): """Collection of metric configurations. Variables are only populated by the server, and will be ignored when sending a request. @@ -3112,67 +3366,64 @@ class MonitoringMetricConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MonitoringMetricConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MonitoringMetricConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class MountPointMap(msrest.serialization.Model): +class MountPointMap(_serialization.Model): """The share mount point. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str + :ivar share_id: ID of the share mounted to the role VM. Required. + :vartype share_id: str :ivar role_id: ID of the role to which share is mounted. :vartype role_id: str :ivar mount_point: Mount point for the share. :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". + :ivar mount_type: Mounting type. Known values are: "Volume" and "HostPath". :vartype mount_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive", - "MEC", "CloudEdgeManagement", "Kubernetes". + :ivar role_type: Role type. Known values are: "IOT", "ASA", "Functions", "Cognitive", "MEC", + "CloudEdgeManagement", and "Kubernetes". :vartype role_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.RoleTypes """ _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, + "share_id": {"required": True}, + "role_id": {"readonly": True}, + "mount_point": {"readonly": True}, + "mount_type": {"readonly": True}, + "role_type": {"readonly": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "mount_point": {"key": "mountPoint", "type": "str"}, + "mount_type": {"key": "mountType", "type": "str"}, + "role_type": {"key": "roleType", "type": "str"}, + } + + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: ID of the share mounted to the role VM. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id self.role_id = None self.mount_point = None @@ -3180,7 +3431,7 @@ def __init__( self.role_type = None -class NetworkAdapter(msrest.serialization.Model): +class NetworkAdapter(_serialization.Model): # pylint: disable=too-many-instance-attributes """Represents the networkAdapter on a device. Variables are only populated by the server, and will be ignored when sending a request. @@ -3200,16 +3451,18 @@ class NetworkAdapter(msrest.serialization.Model): :ivar mac_address: MAC address. :vartype mac_address: str :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". + :vartype link_speed: int + :ivar status: Value indicating whether this adapter is valid. Known values are: "Inactive" and + "Active". :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterDHCPStatus + :ivar rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :vartype rdma_status: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterRDMAStatus + :ivar dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :vartype dhcp_status: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterDHCPStatus :ivar ipv4_configuration: The IPv4 configuration of the network adapter. :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2020_09_01.models.Ipv4Config :ivar ipv6_configuration: The IPv6 configuration of the network adapter. @@ -3221,47 +3474,57 @@ class NetworkAdapter(msrest.serialization.Model): """ _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, + "adapter_id": {"readonly": True}, + "adapter_position": {"readonly": True}, + "index": {"readonly": True}, + "node_id": {"readonly": True}, + "network_adapter_name": {"readonly": True}, + "label": {"readonly": True}, + "mac_address": {"readonly": True}, + "link_speed": {"readonly": True}, + "status": {"readonly": True}, + "ipv4_configuration": {"readonly": True}, + "ipv6_configuration": {"readonly": True}, + "ipv6_link_local_address": {"readonly": True}, + "dns_servers": {"readonly": True}, } _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, + "adapter_id": {"key": "adapterId", "type": "str"}, + "adapter_position": {"key": "adapterPosition", "type": "NetworkAdapterPosition"}, + "index": {"key": "index", "type": "int"}, + "node_id": {"key": "nodeId", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "mac_address": {"key": "macAddress", "type": "str"}, + "link_speed": {"key": "linkSpeed", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "rdma_status": {"key": "rdmaStatus", "type": "str"}, + "dhcp_status": {"key": "dhcpStatus", "type": "str"}, + "ipv4_configuration": {"key": "ipv4Configuration", "type": "Ipv4Config"}, + "ipv6_configuration": {"key": "ipv6Configuration", "type": "Ipv6Config"}, + "ipv6_link_local_address": {"key": "ipv6LinkLocalAddress", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, } def __init__( self, *, - rdma_status: Optional[Union[str, "NetworkAdapterRDMAStatus"]] = None, - dhcp_status: Optional[Union[str, "NetworkAdapterDHCPStatus"]] = None, + rdma_status: Optional[Union[str, "_models.NetworkAdapterRDMAStatus"]] = None, + dhcp_status: Optional[Union[str, "_models.NetworkAdapterDHCPStatus"]] = None, **kwargs ): - super(NetworkAdapter, self).__init__(**kwargs) + """ + :keyword rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :paramtype rdma_status: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterRDMAStatus + :keyword dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :paramtype dhcp_status: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkAdapterDHCPStatus + """ + super().__init__(**kwargs) self.adapter_id = None self.adapter_position = None self.index = None @@ -3279,32 +3542,30 @@ def __init__( self.dns_servers = None -class NetworkAdapterPosition(msrest.serialization.Model): +class NetworkAdapterPosition(_serialization.Model): """The network adapter position. Variables are only populated by the server, and will be ignored when sending a request. - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". + :ivar network_group: The network group. Known values are: "None", "NonRDMA", and "RDMA". :vartype network_group: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkGroup :ivar port: The port. :vartype port: int """ _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, + "network_group": {"readonly": True}, + "port": {"readonly": True}, } _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, + "network_group": {"key": "networkGroup", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_group = None self.port = None @@ -3325,89 +3586,85 @@ class NetworkSettings(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "network_adapters": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "network_adapters": {"key": "properties.networkAdapters", "type": "[NetworkAdapter]"}, } - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_adapters = None class Node(ARMBaseModel): """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str + Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node + Multi-node Edge devices will have more than 1 nodes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar node_status: The current status of the individual node. Known values are: "Unknown", + "Up", "Down", "Rebooting", and "ShuttingDown". + :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.NodeStatus + :ivar node_chassis_serial_number: Serial number of the Chassis. + :vartype node_chassis_serial_number: str + :ivar node_serial_number: Serial number of the individual node. + :vartype node_serial_number: str + :ivar node_display_name: Display Name of the individual node. + :vartype node_display_name: str + :ivar node_friendly_software_version: Friendly software version name that is currently + installed on the node. + :vartype node_friendly_software_version: str + :ivar node_hcs_version: HCS version that is currently installed on the node. + :vartype node_hcs_version: str + :ivar node_instance_id: Guid instance id of the node. + :vartype node_instance_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "node_status": {"readonly": True}, + "node_chassis_serial_number": {"readonly": True}, + "node_serial_number": {"readonly": True}, + "node_display_name": {"readonly": True}, + "node_friendly_software_version": {"readonly": True}, + "node_hcs_version": {"readonly": True}, + "node_instance_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "node_status": {"key": "properties.nodeStatus", "type": "str"}, + "node_chassis_serial_number": {"key": "properties.nodeChassisSerialNumber", "type": "str"}, + "node_serial_number": {"key": "properties.nodeSerialNumber", "type": "str"}, + "node_display_name": {"key": "properties.nodeDisplayName", "type": "str"}, + "node_friendly_software_version": {"key": "properties.nodeFriendlySoftwareVersion", "type": "str"}, + "node_hcs_version": {"key": "properties.nodeHcsVersion", "type": "str"}, + "node_instance_id": {"key": "properties.nodeInstanceId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.node_status = None self.node_chassis_serial_number = None self.node_serial_number = None @@ -3417,108 +3674,120 @@ def __init__( self.node_instance_id = None -class NodeInfo(msrest.serialization.Model): +class NodeInfo(_serialization.Model): """Kubernetes node info. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: Node name. :vartype name: str - :ivar type: Node type - Master/Worker. Possible values include: "Invalid", "Master", "Worker". + :ivar type: Node type - Master/Worker. Known values are: "Invalid", "Master", and "Worker". :vartype type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesNodeType - :param ip_configuration: IP Configuration of the Kubernetes node. - :type ip_configuration: + :ivar ip_configuration: IP Configuration of the Kubernetes node. + :vartype ip_configuration: list[~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesIPConfiguration] """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_configuration': {'key': 'ipConfiguration', 'type': '[KubernetesIPConfiguration]'}, - } - - def __init__( - self, - *, - ip_configuration: Optional[List["KubernetesIPConfiguration"]] = None, - **kwargs - ): - super(NodeInfo, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "ip_configuration": {"key": "ipConfiguration", "type": "[KubernetesIPConfiguration]"}, + } + + def __init__(self, *, ip_configuration: Optional[List["_models.KubernetesIPConfiguration"]] = None, **kwargs): + """ + :keyword ip_configuration: IP Configuration of the Kubernetes node. + :paramtype ip_configuration: + list[~azure.mgmt.databoxedge.v2020_09_01.models.KubernetesIPConfiguration] + """ + super().__init__(**kwargs) self.name = None self.type = None self.ip_configuration = ip_configuration -class NodeList(msrest.serialization.Model): +class NodeList(_serialization.Model): """Collection of Nodes. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of Nodes. :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Node] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Node]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: Optional[str] = None, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) + def __init__(self, *, next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = None self.next_link = next_link -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operations. - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2020_09_01.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param service_specification: Service specification. - :type service_specification: ~azure.mgmt.databoxedge.v2020_09_01.models.ServiceSpecification + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties displayed for the operation. + :vartype display: ~azure.mgmt.databoxedge.v2020_09_01.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar service_specification: Service specification. + :vartype service_specification: ~azure.mgmt.databoxedge.v2020_09_01.models.ServiceSpecification """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, is_data_action: Optional[bool] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): - super(Operation, self).__init__(**kwargs) + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties displayed for the operation. + :paramtype display: ~azure.mgmt.databoxedge.v2020_09_01.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword service_specification: Service specification. + :paramtype service_specification: + ~azure.mgmt.databoxedge.v2020_09_01.models.ServiceSpecification + """ + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin @@ -3526,24 +3795,24 @@ def __init__( self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display properties. - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: The type of resource in which the operation is performed. + :vartype resource: str + :ivar operation: Operation to be performed on the resource. + :vartype operation: str + :ivar description: Description of the operation to be performed. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -3555,46 +3824,56 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: The type of resource in which the operation is performed. + :paramtype resource: str + :keyword operation: Operation to be performed on the resource. + :paramtype operation: str + :keyword description: Description of the operation to be performed. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsList(msrest.serialization.Model): +class OperationsList(_serialization.Model): """The list of operations used for the discovery of available provider operations. All required parameters must be populated in order to send to Azure. - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar value: The value. Required. + :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Operation] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: List["Operation"], - next_link: Optional[str] = None, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The value. Required. + :paramtype value: list[~azure.mgmt.databoxedge.v2020_09_01.models.Operation] + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Order(ARMBaseModel): +class Order(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The order details. Variables are only populated by the server, and will be ignored when sending a request. @@ -3605,10 +3884,10 @@ class Order(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2020_09_01.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2020_09_01.models.Address + :ivar contact_information: The contact details. + :vartype contact_information: ~azure.mgmt.databoxedge.v2020_09_01.models.ContactDetails + :ivar shipping_address: The shipping address. + :vartype shipping_address: ~azure.mgmt.databoxedge.v2020_09_01.models.Address :ivar current_status: Current status of the order. :vartype current_status: ~azure.mgmt.databoxedge.v2020_09_01.models.OrderStatus :ivar order_history: List of status changes in the order. @@ -3621,45 +3900,54 @@ class Order(ARMBaseModel): :ivar return_tracking_info: Tracking information for the package returned from the customer whether it has an original or a replacement device. :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2020_09_01.models.TrackingInfo] - :param shipment_type: ShipmentType of the order. Possible values include: "NotApplicable", - "ShippedToCustomer", "SelfPickup". - :type shipment_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShipmentType + :ivar shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :vartype shipment_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShipmentType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'current_status': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "current_status": {"readonly": True}, + "order_history": {"readonly": True}, + "serial_number": {"readonly": True}, + "delivery_tracking_info": {"readonly": True}, + "return_tracking_info": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - 'shipment_type': {'key': 'properties.shipmentType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "contact_information": {"key": "properties.contactInformation", "type": "ContactDetails"}, + "shipping_address": {"key": "properties.shippingAddress", "type": "Address"}, + "current_status": {"key": "properties.currentStatus", "type": "OrderStatus"}, + "order_history": {"key": "properties.orderHistory", "type": "[OrderStatus]"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "delivery_tracking_info": {"key": "properties.deliveryTrackingInfo", "type": "[TrackingInfo]"}, + "return_tracking_info": {"key": "properties.returnTrackingInfo", "type": "[TrackingInfo]"}, + "shipment_type": {"key": "properties.shipmentType", "type": "str"}, } def __init__( self, *, - contact_information: Optional["ContactDetails"] = None, - shipping_address: Optional["Address"] = None, - shipment_type: Optional[Union[str, "ShipmentType"]] = None, + contact_information: Optional["_models.ContactDetails"] = None, + shipping_address: Optional["_models.Address"] = None, + shipment_type: Optional[Union[str, "_models.ShipmentType"]] = None, **kwargs ): - super(Order, self).__init__(**kwargs) + """ + :keyword contact_information: The contact details. + :paramtype contact_information: ~azure.mgmt.databoxedge.v2020_09_01.models.ContactDetails + :keyword shipping_address: The shipping address. + :paramtype shipping_address: ~azure.mgmt.databoxedge.v2020_09_01.models.Address + :keyword shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :paramtype shipment_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShipmentType + """ + super().__init__(**kwargs) self.contact_information = contact_information self.shipping_address = shipping_address self.current_status = None @@ -3670,7 +3958,7 @@ def __init__( self.shipment_type = shipment_type -class OrderList(msrest.serialization.Model): +class OrderList(_serialization.Model): """List of order entities. Variables are only populated by the server, and will be ignored when sending a request. @@ -3682,41 +3970,39 @@ class OrderList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Order]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OrderStatus(msrest.serialization.Model): +class OrderStatus(_serialization.Model): """Represents a single status change. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", - "AwaitingPickup", "PickupCompleted", "AwaitingDrop". - :type status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.OrderState + :ivar status: Status of the order as per the allowed status types. Required. Known values are: + "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.OrderState :ivar update_date_time: Time of status update. :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str + :ivar comments: Comments related to this status change. + :vartype comments: str :ivar tracking_information: Tracking information related to the state in the ordering flow. :vartype tracking_information: ~azure.mgmt.databoxedge.v2020_09_01.models.TrackingInfo :ivar additional_order_details: Dictionary to hold generic information which is not stored @@ -3725,28 +4011,32 @@ class OrderStatus(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'tracking_information': {'readonly': True}, - 'additional_order_details': {'readonly': True}, + "status": {"required": True}, + "update_date_time": {"readonly": True}, + "tracking_information": {"readonly": True}, + "additional_order_details": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'tracking_information': {'key': 'trackingInformation', 'type': 'TrackingInfo'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - *, - status: Union[str, "OrderState"], - comments: Optional[str] = None, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) + "status": {"key": "status", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + "comments": {"key": "comments", "type": "str"}, + "tracking_information": {"key": "trackingInformation", "type": "TrackingInfo"}, + "additional_order_details": {"key": "additionalOrderDetails", "type": "{str}"}, + } + + def __init__(self, *, status: Union[str, "_models.OrderState"], comments: Optional[str] = None, **kwargs): + """ + :keyword status: Status of the order as per the allowed status types. Required. Known values + are: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :paramtype status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.OrderState + :keyword comments: Comments related to this status change. + :paramtype comments: str + """ + super().__init__(**kwargs) self.status = status self.update_date_time = None self.comments = comments @@ -3769,122 +4059,135 @@ class PeriodicTimerEventTrigger(Trigger): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2020_09_01.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2020_09_01.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01.models.TriggerEventType + :ivar source_info: Periodic timer details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2020_09_01.models.PeriodicTimerSourceInfo + :ivar sink_info: Role Sink information. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2020_09_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "PeriodicTimerSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "PeriodicTimerSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.PeriodicTimerSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str + """ + :keyword source_info: Periodic timer details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2020_09_01.models.PeriodicTimerSourceInfo + :keyword sink_info: Role Sink information. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2020_09_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "PeriodicTimerEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class PeriodicTimerSourceInfo(msrest.serialization.Model): +class PeriodicTimerSourceInfo(_serialization.Model): """Periodic timer event source. All required parameters must be populated in order to send to Azure. - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str + :ivar start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :vartype start_time: ~datetime.datetime + :ivar schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :vartype schedule: str + :ivar topic: Topic where periodic events are published to IoT device. + :vartype topic: str """ _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, + "start_time": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - *, - start_time: datetime.datetime, - schedule: str, - topic: Optional[str] = None, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) + "start_time": {"key": "startTime", "type": "iso-8601"}, + "schedule": {"key": "schedule", "type": "str"}, + "topic": {"key": "topic", "type": "str"}, + } + + def __init__(self, *, start_time: datetime.datetime, schedule: str, topic: Optional[str] = None, **kwargs): + """ + :keyword start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :paramtype start_time: ~datetime.datetime + :keyword schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :paramtype schedule: str + :keyword topic: Topic where periodic events are published to IoT device. + :paramtype topic: str + """ + super().__init__(**kwargs) self.start_time = start_time self.schedule = schedule self.topic = topic -class RefreshDetails(msrest.serialization.Model): +class RefreshDetails(_serialization.Model): """Fields for tracking refresh job on the share or container. - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + :ivar in_progress_refresh_job_id: If a refresh job is currently in progress on this share or container, this field indicates the ARM resource ID of that job. The field is empty if no job is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh + :vartype in_progress_refresh_job_id: str + :ivar last_completed_refresh_job_time_in_utc: Indicates the completed time for the last refresh + job on this particular share or container, if any.This could be a failed job or a successful + job. + :vartype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :ivar error_manifest_file: Indicates the relative path of the error xml for the last refresh job on this particular share or container, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or + :vartype error_manifest_file: str + :ivar last_job: Indicates the id of the last refresh job on this particular share or container,if any. This could be a failed job or a successful job. - :type last_job: str + :vartype last_job: str """ _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, + "in_progress_refresh_job_id": {"key": "inProgressRefreshJobId", "type": "str"}, + "last_completed_refresh_job_time_in_utc": {"key": "lastCompletedRefreshJobTimeInUTC", "type": "iso-8601"}, + "error_manifest_file": {"key": "errorManifestFile", "type": "str"}, + "last_job": {"key": "lastJob", "type": "str"}, } def __init__( @@ -3896,20 +4199,37 @@ def __init__( last_job: Optional[str] = None, **kwargs ): - super(RefreshDetails, self).__init__(**kwargs) + """ + :keyword in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + container, this field indicates the ARM resource ID of that job. The field is empty if no job + is in progress. + :paramtype in_progress_refresh_job_id: str + :keyword last_completed_refresh_job_time_in_utc: Indicates the completed time for the last + refresh job on this particular share or container, if any.This could be a failed job or a + successful job. + :paramtype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :keyword error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share or container, if any. This could be a failed job or a successful + job. + :paramtype error_manifest_file: str + :keyword last_job: Indicates the id of the last refresh job on this particular share or + container,if any. This could be a failed job or a successful job. + :paramtype last_job: str + """ + super().__init__(**kwargs) self.in_progress_refresh_job_id = in_progress_refresh_job_id self.last_completed_refresh_job_time_in_utc = last_completed_refresh_job_time_in_utc self.error_manifest_file = error_manifest_file self.last_job = last_job -class ResourceIdentity(msrest.serialization.Model): +class ResourceIdentity(_serialization.Model): """Msi identity details of the resource. Variables are only populated by the server, and will be ignored when sending a request. - :param type: Identity type. Possible values include: "None", "SystemAssigned", "UserAssigned". - :type type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MsiIdentityType + :ivar type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :vartype type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MsiIdentityType :ivar principal_id: Service Principal Id backing the Msi. :vartype principal_id: str :ivar tenant_id: Home Tenant Id. @@ -3917,58 +4237,66 @@ class ResourceIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "MsiIdentityType"]] = None, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) + def __init__(self, *, type: Optional[Union[str, "_models.MsiIdentityType"]] = None, **kwargs): + """ + :keyword type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :paramtype type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MsiIdentityType + """ + super().__init__(**kwargs) self.type = type self.principal_id = None self.tenant_id = None -class ResourceMoveDetails(msrest.serialization.Model): +class ResourceMoveDetails(_serialization.Model): """Fields for tracking resource move. - :param operation_in_progress: Denotes whether move operation is in progress. Possible values - include: "None", "ResourceMoveInProgress", "ResourceMoveFailed". - :type operation_in_progress: str or + :ivar operation_in_progress: Denotes whether move operation is in progress. Known values are: + "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :vartype operation_in_progress: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceMoveStatus - :param operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + :ivar operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to finish. - :type operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + :vartype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime """ _attribute_map = { - 'operation_in_progress': {'key': 'operationInProgress', 'type': 'str'}, - 'operation_in_progress_lock_timeout_in_utc': {'key': 'operationInProgressLockTimeoutInUTC', 'type': 'iso-8601'}, + "operation_in_progress": {"key": "operationInProgress", "type": "str"}, + "operation_in_progress_lock_timeout_in_utc": {"key": "operationInProgressLockTimeoutInUTC", "type": "iso-8601"}, } def __init__( self, *, - operation_in_progress: Optional[Union[str, "ResourceMoveStatus"]] = None, + operation_in_progress: Optional[Union[str, "_models.ResourceMoveStatus"]] = None, operation_in_progress_lock_timeout_in_utc: Optional[datetime.datetime] = None, **kwargs ): - super(ResourceMoveDetails, self).__init__(**kwargs) + """ + :keyword operation_in_progress: Denotes whether move operation is in progress. Known values + are: "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :paramtype operation_in_progress: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.ResourceMoveStatus + :keyword operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + finish. + :paramtype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + """ + super().__init__(**kwargs) self.operation_in_progress = operation_in_progress self.operation_in_progress_lock_timeout_in_utc = operation_in_progress_lock_timeout_in_utc -class ResourceTypeSku(msrest.serialization.Model): +class ResourceTypeSku(_serialization.Model): """Resource type Sku object. Variables are only populated by the server, and will be ignored when sending a request. @@ -3980,25 +4308,23 @@ class ResourceTypeSku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'skus': {'readonly': True}, + "resource_type": {"readonly": True}, + "skus": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'skus': {'key': 'skus', 'type': '[SkuInformation]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "skus": {"key": "skus", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.skus = None -class RoleList(msrest.serialization.Model): +class RoleList(_serialization.Model): """Collection of all the roles on the Data Box Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4010,48 +4336,45 @@ class RoleList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Role]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RoleSinkInfo(msrest.serialization.Model): +class RoleSinkInfo(_serialization.Model): """Compute role against which events will be raised. All required parameters must be populated in order to send to Azure. - :param role_id: Required. Compute role ID. - :type role_id: str + :ivar role_id: Compute role ID. Required. + :vartype role_id: str """ _validation = { - 'role_id': {'required': True}, + "role_id": {"required": True}, } _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, + "role_id": {"key": "roleId", "type": "str"}, } - def __init__( - self, - *, - role_id: str, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) + def __init__(self, *, role_id: str, **kwargs): + """ + :keyword role_id: Compute role ID. Required. + :paramtype role_id: str + """ + super().__init__(**kwargs) self.role_id = role_id @@ -4068,61 +4391,64 @@ class SecuritySettings(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: + :ivar device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :vartype device_admin_password: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "device_admin_password": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - *, - device_admin_password: "AsymmetricEncryptedSecret", - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_admin_password": {"key": "properties.deviceAdminPassword", "type": "AsymmetricEncryptedSecret"}, + } + + def __init__(self, *, device_admin_password: "_models.AsymmetricEncryptedSecret", **kwargs): + """ + :keyword device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :paramtype device_admin_password: + ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.device_admin_password = device_admin_password -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification. - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: + :ivar metric_specifications: Metric specification as defined by shoebox. + :vartype metric_specifications: list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricSpecificationV1] """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecificationV1]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["MetricSpecificationV1"]] = None, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecificationV1"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specification as defined by shoebox. + :paramtype metric_specifications: + list[~azure.mgmt.databoxedge.v2020_09_01.models.MetricSpecificationV1] + """ + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Share(ARMBaseModel): +class Share(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Represents a share on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4137,76 +4463,105 @@ class Share(ARMBaseModel): :vartype type: str :ivar system_data: Share on ASE device. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share + :ivar description: Description for the share. + :vartype description: str + :ivar share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :vartype share_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareStatus + :ivar monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :vartype monitoring_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringStatus + :ivar azure_container_info: Azure container mapping for the share. + :vartype azure_container_info: ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerInfo + :ivar access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :vartype access_protocol: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessProtocol + :ivar user_access_rights: Mapping of users and corresponding access rights on the share (required for SMB protocol). - :type user_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the + :vartype user_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01.models.UserAccessRight] + :ivar client_access_rights: List of IP addresses and corresponding access rights on the share(required for NFS protocol). - :type client_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2020_09_01.models.RefreshDetails + :vartype client_access_rights: + list[~azure.mgmt.databoxedge.v2020_09_01.models.ClientAccessRight] + :ivar refresh_details: Details of the refresh job on this share. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_09_01.models.RefreshDetails :ivar share_mappings: Share mount point to the role. :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataPolicy + :ivar data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_status": {"required": True}, + "monitoring_status": {"required": True}, + "access_protocol": {"required": True}, + "share_mappings": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "share_status": {"key": "properties.shareStatus", "type": "str"}, + "monitoring_status": {"key": "properties.monitoringStatus", "type": "str"}, + "azure_container_info": {"key": "properties.azureContainerInfo", "type": "AzureContainerInfo"}, + "access_protocol": {"key": "properties.accessProtocol", "type": "str"}, + "user_access_rights": {"key": "properties.userAccessRights", "type": "[UserAccessRight]"}, + "client_access_rights": {"key": "properties.clientAccessRights", "type": "[ClientAccessRight]"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, } def __init__( self, *, - share_status: Union[str, "ShareStatus"], - monitoring_status: Union[str, "MonitoringStatus"], - access_protocol: Union[str, "ShareAccessProtocol"], + share_status: Union[str, "_models.ShareStatus"], + monitoring_status: Union[str, "_models.MonitoringStatus"], + access_protocol: Union[str, "_models.ShareAccessProtocol"], description: Optional[str] = None, - azure_container_info: Optional["AzureContainerInfo"] = None, - user_access_rights: Optional[List["UserAccessRight"]] = None, - client_access_rights: Optional[List["ClientAccessRight"]] = None, - refresh_details: Optional["RefreshDetails"] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, + azure_container_info: Optional["_models.AzureContainerInfo"] = None, + user_access_rights: Optional[List["_models.UserAccessRight"]] = None, + client_access_rights: Optional[List["_models.ClientAccessRight"]] = None, + refresh_details: Optional["_models.RefreshDetails"] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, **kwargs ): - super(Share, self).__init__(**kwargs) + """ + :keyword description: Description for the share. + :paramtype description: str + :keyword share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :paramtype share_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareStatus + :keyword monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :paramtype monitoring_status: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringStatus + :keyword azure_container_info: Azure container mapping for the share. + :paramtype azure_container_info: ~azure.mgmt.databoxedge.v2020_09_01.models.AzureContainerInfo + :keyword access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :paramtype access_protocol: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessProtocol + :keyword user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :paramtype user_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01.models.UserAccessRight] + :keyword client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :paramtype client_access_rights: + list[~azure.mgmt.databoxedge.v2020_09_01.models.ClientAccessRight] + :keyword refresh_details: Details of the refresh job on this share. + :paramtype refresh_details: ~azure.mgmt.databoxedge.v2020_09_01.models.RefreshDetails + :keyword data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataPolicy + """ + super().__init__(**kwargs) self.system_data = None self.description = description self.share_status = share_status @@ -4220,41 +4575,42 @@ def __init__( self.data_policy = data_policy -class ShareAccessRight(msrest.serialization.Model): +class ShareAccessRight(_serialization.Model): """Specifies the mapping between this particular user and the type of access he has on shares on this device. All required parameters must be populated in order to send to Azure. - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessType + :ivar share_id: The share ID. Required. + :vartype share_id: str + :ivar access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessType """ _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, + "share_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, share_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword share_id: The share ID. Required. + :paramtype share_id: str + :keyword access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.share_id = share_id self.access_type = access_type -class ShareList(msrest.serialization.Model): +class ShareList(_serialization.Model): """Collection of all the shares on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4266,54 +4622,61 @@ class ShareList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Share]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU type. - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". - :type name: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuTier + :ivar name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", and "RDC". + :vartype name: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuTier """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "SkuName"]] = None, - tier: Optional[Union[str, "SkuTier"]] = None, + name: Optional[Union[str, "_models.SkuName"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, **kwargs ): - super(Sku, self).__init__(**kwargs) + """ + :keyword name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", and "RDC". + :paramtype name: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuName + :keyword tier: The SKU tier. This is based on the SKU name. "Standard" + :paramtype tier: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SkuTier + """ + super().__init__(**kwargs) self.name = name self.tier = tier -class SkuCost(msrest.serialization.Model): +class SkuCost(_serialization.Model): """The metadata for retrieving price info. Variables are only populated by the server, and will be ignored when sending a request. @@ -4321,34 +4684,32 @@ class SkuCost(msrest.serialization.Model): :ivar meter_id: Used for querying price from commerce. :vartype meter_id: str :ivar quantity: The cost quantity. - :vartype quantity: long + :vartype quantity: int :ivar extended_unit: The extended unit. :vartype extended_unit: str """ _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, + "meter_id": {"readonly": True}, + "quantity": {"readonly": True}, + "extended_unit": {"readonly": True}, } _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, + "meter_id": {"key": "meterId", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.meter_id = None self.quantity = None self.extended_unit = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Sku information. Variables are only populated by the server, and will be ignored when sending a request. @@ -4374,34 +4735,32 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'family': {'readonly': True}, - 'costs': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, + "name": {"readonly": True}, + "tier": {"readonly": True}, + "kind": {"readonly": True}, + "family": {"readonly": True}, + "costs": {"readonly": True}, + "locations": {"readonly": True}, + "location_info": {"readonly": True}, + "required_quota_ids": {"readonly": True}, + "required_features": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "required_quota_ids": {"key": "requiredQuotaIds", "type": "[str]"}, + "required_features": {"key": "requiredFeatures", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.tier = None self.kind = None @@ -4413,7 +4772,7 @@ def __init__( self.required_features = None -class SkuInformationList(msrest.serialization.Model): +class SkuInformationList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -4425,25 +4784,23 @@ class SkuInformationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceTypeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SkuLocationInfo(msrest.serialization.Model): +class SkuLocationInfo(_serialization.Model): """The location info. Variables are only populated by the server, and will be ignored when sending a request. @@ -4457,22 +4814,20 @@ class SkuLocationInfo(msrest.serialization.Model): """ _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, + "location": {"readonly": True}, + "zones": {"readonly": True}, + "sites": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "sites": {"key": "sites", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.zones = None self.sites = None @@ -4493,17 +4848,17 @@ class StorageAccount(ARMBaseModel): :vartype type: str :ivar system_data: StorageAccount object on ASE device. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or + :ivar description: Description for the storage Account. + :vartype description: str + :ivar storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :vartype storage_account_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountStatus - :param data_policy: Required. Data policy of the storage Account. Possible values include: - "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str + :ivar data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" and + "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataPolicy + :ivar storage_account_credential_id: Storage Account Credential Id. + :vartype storage_account_credential_id: str :ivar blob_endpoint: BlobEndpoint of Storage Account. :vartype blob_endpoint: str :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy @@ -4512,38 +4867,51 @@ class StorageAccount(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'data_policy': {'required': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "data_policy": {"required": True}, + "blob_endpoint": {"readonly": True}, + "container_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "storage_account_status": {"key": "properties.storageAccountStatus", "type": "str"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, + "storage_account_credential_id": {"key": "properties.storageAccountCredentialId", "type": "str"}, + "blob_endpoint": {"key": "properties.blobEndpoint", "type": "str"}, + "container_count": {"key": "properties.containerCount", "type": "int"}, } def __init__( self, *, - data_policy: Union[str, "DataPolicy"], + data_policy: Union[str, "_models.DataPolicy"], description: Optional[str] = None, - storage_account_status: Optional[Union[str, "StorageAccountStatus"]] = None, + storage_account_status: Optional[Union[str, "_models.StorageAccountStatus"]] = None, storage_account_credential_id: Optional[str] = None, **kwargs ): - super(StorageAccount, self).__init__(**kwargs) + """ + :keyword description: Description for the storage Account. + :paramtype description: str + :keyword storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :paramtype storage_account_status: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountStatus + :keyword data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" + and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DataPolicy + :keyword storage_account_credential_id: Storage Account Credential Id. + :paramtype storage_account_credential_id: str + """ + super().__init__(**kwargs) self.system_data = None self.description = description self.storage_account_status = storage_account_status @@ -4553,7 +4921,7 @@ def __init__( self.container_count = None -class StorageAccountCredential(ARMBaseModel): +class StorageAccountCredential(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The storage account credential. Variables are only populated by the server, and will be ignored when sending a request. @@ -4568,66 +4936,87 @@ class StorageAccountCredential(ARMBaseModel): :vartype type: str :ivar system_data: StorageAccountCredential object. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str + :ivar alias: Alias for the storage account. Required. + :vartype alias: str + :ivar user_name: Username for the storage account. + :vartype user_name: str + :ivar account_key: Encrypted storage key. + :vartype account_key: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string for the storage account. Use this string if username + and account key are not specified. + :vartype connection_string: str + :ivar ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values are: + "Enabled" and "Disabled". + :vartype ssl_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SSLStatus + :ivar blob_domain_name: Blob end point for private clouds. + :vartype blob_domain_name: str + :ivar account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :vartype account_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AccountType + :ivar storage_account_id: Id of the storage account. + :vartype storage_account_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "alias": {"required": True}, + "ssl_status": {"required": True}, + "account_type": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "alias": {"key": "properties.alias", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "account_key": {"key": "properties.accountKey", "type": "AsymmetricEncryptedSecret"}, + "connection_string": {"key": "properties.connectionString", "type": "str"}, + "ssl_status": {"key": "properties.sslStatus", "type": "str"}, + "blob_domain_name": {"key": "properties.blobDomainName", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, } def __init__( self, *, alias: str, - ssl_status: Union[str, "SSLStatus"], - account_type: Union[str, "AccountType"], + ssl_status: Union[str, "_models.SSLStatus"], + account_type: Union[str, "_models.AccountType"], user_name: Optional[str] = None, - account_key: Optional["AsymmetricEncryptedSecret"] = None, + account_key: Optional["_models.AsymmetricEncryptedSecret"] = None, connection_string: Optional[str] = None, blob_domain_name: Optional[str] = None, storage_account_id: Optional[str] = None, **kwargs ): - super(StorageAccountCredential, self).__init__(**kwargs) + """ + :keyword alias: Alias for the storage account. Required. + :paramtype alias: str + :keyword user_name: Username for the storage account. + :paramtype user_name: str + :keyword account_key: Encrypted storage key. + :paramtype account_key: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + :keyword connection_string: Connection string for the storage account. Use this string if + username and account key are not specified. + :paramtype connection_string: str + :keyword ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values + are: "Enabled" and "Disabled". + :paramtype ssl_status: str or ~azure.mgmt.databoxedge.v2020_09_01.models.SSLStatus + :keyword blob_domain_name: Blob end point for private clouds. + :paramtype blob_domain_name: str + :keyword account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :paramtype account_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AccountType + :keyword storage_account_id: Id of the storage account. + :paramtype storage_account_id: str + """ + super().__init__(**kwargs) self.system_data = None self.alias = alias self.user_name = user_name @@ -4639,7 +5028,7 @@ def __init__( self.storage_account_id = storage_account_id -class StorageAccountCredentialList(msrest.serialization.Model): +class StorageAccountCredentialList(_serialization.Model): """The collection of storage account credentials. Variables are only populated by the server, and will be ignored when sending a request. @@ -4651,25 +5040,23 @@ class StorageAccountCredentialList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccountCredential]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountList(msrest.serialization.Model): +class StorageAccountList(_serialization.Model): """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4681,111 +5068,127 @@ class StorageAccountList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SubscriptionRegisteredFeatures(msrest.serialization.Model): +class SubscriptionRegisteredFeatures(_serialization.Model): """SubscriptionRegisteredFeatures. - :param name: - :type name: str - :param state: - :type state: str + :ivar name: + :vartype name: str + :ivar state: + :vartype state: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - state: Optional[str] = None, - **kwargs - ): - super(SubscriptionRegisteredFeatures, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, state: Optional[str] = None, **kwargs): + """ + :keyword name: + :paramtype name: str + :keyword state: + :paramtype state: str + """ + super().__init__(**kwargs) self.name = name self.state = state -class SymmetricKey(msrest.serialization.Model): +class SymmetricKey(_serialization.Model): """Symmetric key for authentication. - :param connection_string: Connection string based on the symmetric key. - :type connection_string: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string based on the symmetric key. + :vartype connection_string: + ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret """ _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, + "connection_string": {"key": "connectionString", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) + def __init__(self, *, connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs): + """ + :keyword connection_string: Connection string based on the symmetric key. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.connection_string = connection_string -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime + :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", and "Key". + :vartype created_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.CreatedByType + :ivar last_modified_at: The type of identity that last modified the resource. + :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'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_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, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(SystemData, self).__init__(**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", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.CreatedByType + :keyword last_modified_at: The type of identity that last modified the resource. + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -4794,24 +5197,24 @@ def __init__( self.last_modified_at = last_modified_at -class TrackingInfo(msrest.serialization.Model): +class TrackingInfo(_serialization.Model): """Tracking courier information. - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str + :ivar serial_number: Serial number of the device being tracked. + :vartype serial_number: str + :ivar carrier_name: Name of the carrier used in the delivery. + :vartype carrier_name: str + :ivar tracking_id: Tracking ID of the shipment. + :vartype tracking_id: str + :ivar tracking_url: Tracking URL of the shipment. + :vartype tracking_url: str """ _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, + "serial_number": {"key": "serialNumber", "type": "str"}, + "carrier_name": {"key": "carrierName", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "tracking_url": {"key": "trackingUrl", "type": "str"}, } def __init__( @@ -4823,14 +5226,24 @@ def __init__( tracking_url: Optional[str] = None, **kwargs ): - super(TrackingInfo, self).__init__(**kwargs) + """ + :keyword serial_number: Serial number of the device being tracked. + :paramtype serial_number: str + :keyword carrier_name: Name of the carrier used in the delivery. + :paramtype carrier_name: str + :keyword tracking_id: Tracking ID of the shipment. + :paramtype tracking_id: str + :keyword tracking_url: Tracking URL of the shipment. + :paramtype tracking_url: str + """ + super().__init__(**kwargs) self.serial_number = serial_number self.carrier_name = carrier_name self.tracking_id = tracking_id self.tracking_url = tracking_url -class TriggerList(msrest.serialization.Model): +class TriggerList(_serialization.Model): """Collection of all trigger on the data box edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4842,31 +5255,29 @@ class TriggerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Trigger]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class UpdateDownloadProgress(msrest.serialization.Model): +class UpdateDownloadProgress(_serialization.Model): """Details about the download progress of update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". + :ivar download_phase: The download phase. Known values are: "Unknown", "Initializing", + "Downloading", and "Verifying". :vartype download_phase: str or ~azure.mgmt.databoxedge.v2020_09_01.models.DownloadPhase :ivar percent_complete: Percentage of completion. :vartype percent_complete: int @@ -4881,28 +5292,26 @@ class UpdateDownloadProgress(msrest.serialization.Model): """ _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, + "download_phase": {"readonly": True}, + "percent_complete": {"readonly": True}, + "total_bytes_to_download": {"readonly": True}, + "total_bytes_downloaded": {"readonly": True}, + "number_of_updates_to_download": {"readonly": True}, + "number_of_updates_downloaded": {"readonly": True}, } _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, + "download_phase": {"key": "downloadPhase", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "total_bytes_to_download": {"key": "totalBytesToDownload", "type": "float"}, + "total_bytes_downloaded": {"key": "totalBytesDownloaded", "type": "float"}, + "number_of_updates_to_download": {"key": "numberOfUpdatesToDownload", "type": "int"}, + "number_of_updates_downloaded": {"key": "numberOfUpdatesDownloaded", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.download_phase = None self.percent_complete = None self.total_bytes_to_download = None @@ -4911,7 +5320,7 @@ def __init__( self.number_of_updates_downloaded = None -class UpdateInstallProgress(msrest.serialization.Model): +class UpdateInstallProgress(_serialization.Model): """Progress details during installation of updates. Variables are only populated by the server, and will be ignored when sending a request. @@ -4925,28 +5334,26 @@ class UpdateInstallProgress(msrest.serialization.Model): """ _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, + "percent_complete": {"readonly": True}, + "number_of_updates_to_install": {"readonly": True}, + "number_of_updates_installed": {"readonly": True}, } _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "number_of_updates_to_install": {"key": "numberOfUpdatesToInstall", "type": "int"}, + "number_of_updates_installed": {"key": "numberOfUpdatesInstalled", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.percent_complete = None self.number_of_updates_to_install = None self.number_of_updates_installed = None -class UpdateSummary(ARMBaseModel): +class UpdateSummary(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Details about ongoing updates and availability of updates on the device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4957,15 +5364,15 @@ class UpdateSummary(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed + :ivar device_version_number: The current version of the device in format: 1.2.17312.13.",. + :vartype device_version_number: str + :ivar friendly_device_version_name: The current version of the device in text format. + :vartype friendly_device_version_name: str + :ivar device_last_scanned_date_time: The last time when a scan was done on the device. + :vartype device_last_scanned_date_time: ~datetime.datetime + :ivar last_completed_scan_job_date_time: The time when the last scan job was completed (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime + :vartype last_completed_scan_job_date_time: ~datetime.datetime :ivar last_completed_download_job_date_time: The time when the last Download job was completed (success/cancelled/failed) on the appliance. :vartype last_completed_download_job_date_time: ~datetime.datetime @@ -4980,11 +5387,11 @@ class UpdateSummary(ARMBaseModel): :ivar total_number_of_updates_pending_install: The total number of items pending install. :vartype total_number_of_updates_pending_install: int :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.databoxedge.v2020_09_01.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". + :ivar ongoing_update_operation: The current update operation. Known values are: "None", "Scan", + "Download", and "Install". :vartype ongoing_update_operation: str or ~azure.mgmt.databoxedge.v2020_09_01.models.UpdateOperation :ivar in_progress_download_job_id: The job ID of the download job in progress. @@ -5004,45 +5411,63 @@ class UpdateSummary(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_completed_download_job_date_time": {"readonly": True}, + "last_completed_install_job_date_time": {"readonly": True}, + "total_number_of_updates_available": {"readonly": True}, + "total_number_of_updates_pending_download": {"readonly": True}, + "total_number_of_updates_pending_install": {"readonly": True}, + "reboot_behavior": {"readonly": True}, + "ongoing_update_operation": {"readonly": True}, + "in_progress_download_job_id": {"readonly": True}, + "in_progress_install_job_id": {"readonly": True}, + "in_progress_download_job_started_date_time": {"readonly": True}, + "in_progress_install_job_started_date_time": {"readonly": True}, + "update_titles": {"readonly": True}, + "total_update_size_in_bytes": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_version_number": {"key": "properties.deviceVersionNumber", "type": "str"}, + "friendly_device_version_name": {"key": "properties.friendlyDeviceVersionName", "type": "str"}, + "device_last_scanned_date_time": {"key": "properties.deviceLastScannedDateTime", "type": "iso-8601"}, + "last_completed_scan_job_date_time": {"key": "properties.lastCompletedScanJobDateTime", "type": "iso-8601"}, + "last_completed_download_job_date_time": { + "key": "properties.lastCompletedDownloadJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_date_time": { + "key": "properties.lastCompletedInstallJobDateTime", + "type": "iso-8601", + }, + "total_number_of_updates_available": {"key": "properties.totalNumberOfUpdatesAvailable", "type": "int"}, + "total_number_of_updates_pending_download": { + "key": "properties.totalNumberOfUpdatesPendingDownload", + "type": "int", + }, + "total_number_of_updates_pending_install": { + "key": "properties.totalNumberOfUpdatesPendingInstall", + "type": "int", + }, + "reboot_behavior": {"key": "properties.rebootBehavior", "type": "str"}, + "ongoing_update_operation": {"key": "properties.ongoingUpdateOperation", "type": "str"}, + "in_progress_download_job_id": {"key": "properties.inProgressDownloadJobId", "type": "str"}, + "in_progress_install_job_id": {"key": "properties.inProgressInstallJobId", "type": "str"}, + "in_progress_download_job_started_date_time": { + "key": "properties.inProgressDownloadJobStartedDateTime", + "type": "iso-8601", + }, + "in_progress_install_job_started_date_time": { + "key": "properties.inProgressInstallJobStartedDateTime", + "type": "iso-8601", + }, + "update_titles": {"key": "properties.updateTitles", "type": "[str]"}, + "total_update_size_in_bytes": {"key": "properties.totalUpdateSizeInBytes", "type": "float"}, } def __init__( @@ -5054,7 +5479,18 @@ def __init__( last_completed_scan_job_date_time: Optional[datetime.datetime] = None, **kwargs ): - super(UpdateSummary, self).__init__(**kwargs) + """ + :keyword device_version_number: The current version of the device in format: 1.2.17312.13.",. + :paramtype device_version_number: str + :keyword friendly_device_version_name: The current version of the device in text format. + :paramtype friendly_device_version_name: str + :keyword device_last_scanned_date_time: The last time when a scan was done on the device. + :paramtype device_last_scanned_date_time: ~datetime.datetime + :keyword last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :paramtype last_completed_scan_job_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.device_version_number = device_version_number self.friendly_device_version_name = friendly_device_version_name self.device_last_scanned_date_time = device_last_scanned_date_time @@ -5074,47 +5510,56 @@ def __init__( self.total_update_size_in_bytes = None -class UploadCertificateRequest(msrest.serialization.Model): +class UploadCertificateRequest(_serialization.Model): """The upload certificate request. All required parameters must be populated in order to send to Azure. - :param authentication_type: The authentication type. Possible values include: "Invalid", + :ivar authentication_type: The authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type authentication_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str + :vartype authentication_type: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.AuthenticationType + :ivar certificate: The base64 encoded certificate raw data. Required. + :vartype certificate: str """ _validation = { - 'certificate': {'required': True}, + "certificate": {"required": True}, } _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "certificate": {"key": "properties.certificate", "type": "str"}, } def __init__( self, *, certificate: str, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs ): - super(UploadCertificateRequest, self).__init__(**kwargs) + """ + :keyword authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype authentication_type: str or + ~azure.mgmt.databoxedge.v2020_09_01.models.AuthenticationType + :keyword certificate: The base64 encoded certificate raw data. Required. + :paramtype certificate: str + """ + super().__init__(**kwargs) self.authentication_type = authentication_type self.certificate = certificate -class UploadCertificateResponse(msrest.serialization.Model): +class UploadCertificateResponse(_serialization.Model): """The upload registration certificate response. Variables are only populated by the server, and will be ignored when sending a request. - :param auth_type: Specifies authentication type. Possible values include: "Invalid", + :ivar auth_type: Specifies authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AuthenticationType + :vartype auth_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AuthenticationType :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. :vartype resource_id: str :ivar aad_authority: Azure Active Directory tenant authority. @@ -5133,33 +5578,33 @@ class UploadCertificateResponse(msrest.serialization.Model): """ _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, + "resource_id": {"readonly": True}, + "aad_authority": {"readonly": True}, + "aad_tenant_id": {"readonly": True}, + "service_principal_client_id": {"readonly": True}, + "service_principal_object_id": {"readonly": True}, + "azure_management_endpoint_audience": {"readonly": True}, + "aad_audience": {"readonly": True}, } _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - *, - auth_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) + "auth_type": {"key": "authType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "aad_authority": {"key": "aadAuthority", "type": "str"}, + "aad_tenant_id": {"key": "aadTenantId", "type": "str"}, + "service_principal_client_id": {"key": "servicePrincipalClientId", "type": "str"}, + "service_principal_object_id": {"key": "servicePrincipalObjectId", "type": "str"}, + "azure_management_endpoint_audience": {"key": "azureManagementEndpointAudience", "type": "str"}, + "aad_audience": {"key": "aadAudience", "type": "str"}, + } + + def __init__(self, *, auth_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs): + """ + :keyword auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype auth_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.AuthenticationType + """ + super().__init__(**kwargs) self.auth_type = auth_type self.resource_id = None self.aad_authority = None @@ -5183,82 +5628,91 @@ class User(ARMBaseModel): :vartype type: str :ivar system_data: User in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01.models.SystemData - :param encrypted_password: The password details. - :type encrypted_password: ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + :ivar encrypted_password: The password details. + :vartype encrypted_password: + ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret :ivar share_access_rights: List of shares that the user has rights on. This field should not be specified during user creation. :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessRight] - :param user_type: Type of the user. Possible values include: "Share", "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.UserType + :ivar user_type: Type of the user. Known values are: "Share", "LocalManagement", and "ARM". + :vartype user_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.UserType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_access_rights': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_access_rights": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "encrypted_password": {"key": "properties.encryptedPassword", "type": "AsymmetricEncryptedSecret"}, + "share_access_rights": {"key": "properties.shareAccessRights", "type": "[ShareAccessRight]"}, + "user_type": {"key": "properties.userType", "type": "str"}, } def __init__( self, *, - encrypted_password: Optional["AsymmetricEncryptedSecret"] = None, - user_type: Optional[Union[str, "UserType"]] = None, + encrypted_password: Optional["_models.AsymmetricEncryptedSecret"] = None, + user_type: Optional[Union[str, "_models.UserType"]] = None, **kwargs ): - super(User, self).__init__(**kwargs) + """ + :keyword encrypted_password: The password details. + :paramtype encrypted_password: + ~azure.mgmt.databoxedge.v2020_09_01.models.AsymmetricEncryptedSecret + :keyword user_type: Type of the user. Known values are: "Share", "LocalManagement", and "ARM". + :paramtype user_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.UserType + """ + super().__init__(**kwargs) self.system_data = None self.encrypted_password = encrypted_password self.share_access_rights = None self.user_type = user_type -class UserAccessRight(msrest.serialization.Model): +class UserAccessRight(_serialization.Model): """The mapping between a particular user and the access type on the SMB share. All required parameters must be populated in order to send to Azure. - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessType + :ivar user_id: User ID (already existing in the device). Required. + :vartype user_id: str + :ivar access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessType """ _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, + "user_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - user_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) + "user_id": {"key": "userId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, user_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword user_id: User ID (already existing in the device). Required. + :paramtype user_id: str + :keyword access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2020_09_01.models.ShareAccessType + """ + super().__init__(**kwargs) self.user_id = user_id self.access_type = access_type -class UserList(msrest.serialization.Model): +class UserList(_serialization.Model): """Collection of users. Variables are only populated by the server, and will be ignored when sending a request. @@ -5270,19 +5724,17 @@ class UserList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[User]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/__init__.py index d70057be6458..febac852eb27 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/__init__.py @@ -25,23 +25,29 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'AddonsOperations', - 'MonitoringConfigOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_addons_operations.py index 32c85be90393..41c0957dfe4a 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_addons_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,114 +6,274 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_role_request( + device_name: str, role_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, addon_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class AddonsOperations(object): - """AddonsOperations operations. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`addons` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_role( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AddonList"] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Addon"]: """Lists all the addons configured in the role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AddonList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_role.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,122 +282,133 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_role.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + @distributed_trace def get( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Addon" + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: """Gets a specific addon by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } def _create_or_update_initial( self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Addon"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Addon"]] + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(addon, 'Addon') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -245,53 +417,143 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Addon"] + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: """Create or update a addon. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param addon: The addon properties. + :param addon: The addon properties. Required. :type addon: ~azure.mgmt.databoxedge.v2020_09_01.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Addon or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2020_09_01.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -299,80 +561,75 @@ def begin_create_or_update( addon_name=addon_name, resource_group_name=resource_group_name, addon=addon, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -382,79 +639,79 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the addon on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, addon_name=addon_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_alerts_operations.py index 5e475c8ca70b..936f78d0f59d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class AlertsOperations(object): - """AlertsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_by_data_box_edge_device_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,72 +206,73 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_available_skus_operations.py index 739f14c52a86..e3d63cf8a60c 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,153 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } -class AvailableSkusOperations(object): - """AvailableSkusOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeSkuList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,7 +161,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_bandwidth_schedules_operations.py index c08125370b0a..f98ff09a5d00 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,268 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class BandwidthSchedulesOperations(object): - """BandwidthSchedulesOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BandwidthSchedulesList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +276,126 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BandwidthSchedule" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BandwidthSchedule"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +404,215 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BandwidthSchedule"] + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +622,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_containers_operations.py index 18514cba48b2..c06fea4ca504 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,329 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_storage_account_request( + device_name: str, storage_account_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ContainersOperations(object): - """ContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_storage_account( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ContainerList"] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,124 +337,135 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Container" + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Container"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -249,55 +474,149 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Container"] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2020_09_01.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Container or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2020_09_01.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -305,80 +624,75 @@ def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -388,121 +702,116 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -512,81 +821,79 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace def begin_refresh( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_devices_operations.py index 376eeb43c44f..ba64ab2ef43c 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,646 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", + ) # 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"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_download_updates_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_generate_certificate_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_extended_information_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_install_updates_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_settings_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_scan_for_updates_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_security_settings_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_update_extended_information_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class DevicesOperations(object): - """DevicesOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_update_summary_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_upload_certificate_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_subscription( - self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,75 +654,90 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,230 +746,325 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } def _create_or_update_initial( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. + :param data_box_edge_device: The resource object. Required. :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -425,174 +1074,243 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload def update( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDevicePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - def _download_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -602,227 +1320,232 @@ def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } - def begin_download_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_download_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._download_updates_initial( + raw_result = self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace def generate_certificate( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GenerateCertResponse" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: """Generates certificate for activation key. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenerateCertResponse, or the result of cls(response) + :return: GenerateCertResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.GenerateCertResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCertResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.generate_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateCertResponse', pipeline_response) + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate'} # type: ignore + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace def get_extended_information( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - def _install_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -832,168 +1555,170 @@ def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } - def begin_install_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_install_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._install_updates_initial( + raw_result = self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace def get_network_settings( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkSettings" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - def _scan_for_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1003,115 +1728,124 @@ def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def begin_scan_for_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_scan_for_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._scan_for_updates_initial( + raw_result = self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def _create_or_update_security_settings_initial( + def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1121,269 +1855,491 @@ def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload def begin_create_or_update_security_settings( self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2020_09_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2020_09_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_security_settings_initial( + raw_result = self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace def update_extended_information( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDeviceExtendedInfoPatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The patch object. + :param parameters: The patch object. Is either a model type or a IO type. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfoPatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDeviceExtendedInfoPatch') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation'} # type: ignore - def get_update_summary( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateSummary" - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace + def get_update_summary(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload def upload_certificate( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.UploadCertificateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.UploadCertificateResponse" + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_jobs_operations.py index b9023fcd83e1..9f4a3ba6b200 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class JobsOperations(object): - """JobsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_monitoring_config_operations.py index 5036dd1df3ef..7dcce4f038ea 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_monitoring_config_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_monitoring_config_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + device_name: str, role_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class MonitoringConfigOperations(object): - """MonitoringConfigOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MonitoringMetricConfigurationList"] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.MonitoringMetricConfiguration"]: """Lists metric configurations in a role. Lists metric configurations in a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 MonitoringMetricConfigurationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfigurationList', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,118 +283,130 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + @distributed_trace def get( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MonitoringMetricConfiguration" + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: """Gets a metric configuration of a role. Gets a metric configuration of a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringMetricConfiguration, or the result of cls(response) + :return: MonitoringMetricConfiguration or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } def _create_or_update_initial( self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - monitoring_metric_configuration, # type: "_models.MonitoringMetricConfiguration" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MonitoringMetricConfiguration"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MonitoringMetricConfiguration"]] + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(monitoring_metric_configuration, 'MonitoringMetricConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -243,129 +415,223 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - monitoring_metric_configuration, # type: "_models.MonitoringMetricConfiguration" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MonitoringMetricConfiguration"] + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: """Creates a new metric configuration or updates an existing one for a role. Creates a new metric configuration or updates an existing one for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param monitoring_metric_configuration: The metric configuration. - :type monitoring_metric_configuration: ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, monitoring_metric_configuration=monitoring_metric_configuration, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) - + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -375,76 +641,76 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """deletes a new metric configuration for a role. deletes a new metric configuration for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_nodes_operations.py index 098069c8a553..70aebbec51d4 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,166 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class NodesOperations(object): - """NodesOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NodeList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +174,8 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_operations.py index f1df400f6fca..6548f2c2fa65 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") -class Operations(object): - """Operations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataBoxEdge/operations") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +155,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_operations_status_operations.py index a99b8e94cea7..dcb700b8c2ac 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class OperationsStatusOperations(object): - """OperationsStatusOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_orders_operations.py index d580b845a6da..976e86c9685b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,295 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request(device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class OrdersOperations(object): - """OrdersOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_dc_access_code_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OrderList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,112 +303,119 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Order" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } def _create_or_update_initial( - self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Order"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,122 +424,200 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Order"] + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2020_09_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2020_09_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,132 +627,133 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def list_dc_access_code( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DCAccessCode" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace + def list_dc_access_code(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DCAccessCode: """Gets the DCAccess Code. Gets the DCAccess Code. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DCAccessCode, or the result of cls(response) + :return: DCAccessCode or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.DCAccessCode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DCAccessCode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.list_dc_access_code.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DCAccessCode', pipeline_response) + deserialized = self._deserialize("DCAccessCode", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_dc_access_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode'} # type: ignore + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_roles_operations.py index d885cd2fbb11..1fae36d55339 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,267 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class RolesOperations(object): - """RolesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +275,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Role" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Role"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +398,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Role"] + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2020_09_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2020_09_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +604,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_shares_operations.py index 03b97b7f9625..8a9cf71912aa 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,301 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_delete_request( + device_name: str, name: str, 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 {}) -class SharesOperations(object): - """SharesOperations operations. + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ShareList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +309,123 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Share" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Share"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +434,209 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Share"] + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2020_09_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2020_09_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,114 +646,110 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -488,76 +759,74 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } - def begin_refresh( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_refresh(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_storage_account_credentials_operations.py index cd19b75ebc50..da352be8d4f3 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,271 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_create_or_update_request( + device_name: str, name: str, 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 {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -class StorageAccountCredentialsOperations(object): - """StorageAccountCredentialsOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountCredentialList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,116 +279,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountCredential" + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccountCredential"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -237,127 +409,217 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccountCredential"] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -367,74 +629,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_storage_accounts_operations.py index 4d5ae80068de..a25072ee8c27 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,269 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, storage_account_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, storage_account_name: str, 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 {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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, **kwargs) + + +def build_delete_request( + device_name: str, storage_account_name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccount"]: """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +277,130 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccount" + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccount"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +409,221 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccount"] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -371,74 +633,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_triggers_operations.py index f6b42b941e51..2e54946774a7 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,273 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class TriggersOperations(object): - """TriggersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TriggerList"] + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +281,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Trigger" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Trigger"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,127 +404,203 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Trigger"] + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2020_09_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Trigger or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2020_09_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +610,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_users_operations.py index aa8c34b50bf4..5ae5e3d78db3 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,274 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class UsersOperations(object): - """UsersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserList"] + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +282,121 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.User"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,128 +405,206 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.User"] + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2020_09_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2020_09_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -372,74 +614,72 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/__init__.py index e63196b6b98f..d2bcf6a47896 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/__init__.py @@ -7,10 +7,20 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_configuration.py index 47c80b2e85dc..ce4180438f5f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_configuration.py @@ -6,65 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-09-01-preview"] = kwargs.pop("api_version", "2020-09-01-preview") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-09-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_data_box_edge_management_client.py index 71d0d3a836f6..574ab29e3770 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_data_box_edge_management_client.py @@ -6,59 +6,63 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import AddonsOperations -from .operations import MonitoringConfigOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from . import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.databoxedge.v2020_09_01_preview.operations.Operations :ivar available_skus: AvailableSkusOperations operations - :vartype available_skus: azure.mgmt.databoxedge.v2020_09_01_preview.operations.AvailableSkusOperations + :vartype available_skus: + azure.mgmt.databoxedge.v2020_09_01_preview.operations.AvailableSkusOperations :ivar devices: DevicesOperations operations :vartype devices: azure.mgmt.databoxedge.v2020_09_01_preview.operations.DevicesOperations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2020_09_01_preview.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2020_09_01_preview.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2020_09_01_preview.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2020_09_01_preview.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2020_09_01_preview.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2020_09_01_preview.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2020_09_01_preview.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2020_09_01_preview.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -66,109 +70,108 @@ class DataBoxEdgeManagementClient(object): :ivar addons: AddonsOperations operations :vartype addons: azure.mgmt.databoxedge.v2020_09_01_preview.operations.AddonsOperations :ivar monitoring_config: MonitoringConfigOperations operations - :vartype monitoring_config: azure.mgmt.databoxedge.v2020_09_01_preview.operations.MonitoringConfigOperations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2020_09_01_preview.operations.MonitoringConfigOperations :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2020_09_01_preview.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2020_09_01_preview.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2020_09_01_preview.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2020_09_01_preview.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2020_09_01_preview.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations :vartype containers: azure.mgmt.databoxedge.v2020_09_01_preview.operations.ContainersOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2020_09_01_preview.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2020_09_01_preview.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) self.monitoring_config = MonitoringConfigOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None + + 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) -> None: self._client.close() - def __enter__(self): - # type: () -> DataBoxEdgeManagementClient + def __enter__(self) -> "DataBoxEdgeManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_metadata.json b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_metadata.json index 8f4872654ff2..6845a08a9e3b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_metadata.json +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_metadata.json @@ -5,25 +5,25 @@ "name": "DataBoxEdgeManagementClient", "filename": "_data_box_edge_management_client", "description": "The DataBoxEdge Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription ID.", + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription ID.", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=None, # type: Optional[str]", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -117,4 +116,4 @@ "triggers": "TriggersOperations", "users": "UsersOperations" } -} \ No newline at end of file +} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_vendor.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_version.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/__init__.py index c33d46ee91d8..fcb8775eaa10 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_configuration.py index b545e589e3d1..8ef9ab424133 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_configuration.py @@ -6,61 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2020-09-01-preview"] = kwargs.pop("api_version", "2020-09-01-preview") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-09-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_data_box_edge_management_client.py index 7b23ab727068..96b02247ba5f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_data_box_edge_management_client.py @@ -6,57 +6,63 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import AddonsOperations -from .operations import MonitoringConfigOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .. import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.Operations :ivar available_skus: AvailableSkusOperations operations - :vartype available_skus: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.AvailableSkusOperations + :vartype available_skus: + azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.AvailableSkusOperations :ivar devices: DevicesOperations operations :vartype devices: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.DevicesOperations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -64,97 +70,102 @@ class DataBoxEdgeManagementClient(object): :ivar addons: AddonsOperations operations :vartype addons: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.AddonsOperations :ivar monitoring_config: MonitoringConfigOperations operations - :vartype monitoring_config: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.MonitoringConfigOperations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.MonitoringConfigOperations :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations - :vartype containers: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.ContainersOperations + :vartype containers: + azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.ContainersOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2020_09_01_preview.aio.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) self.monitoring_config = MonitoringConfigOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/__init__.py index d70057be6458..febac852eb27 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/__init__.py @@ -25,23 +25,29 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'AddonsOperations', - 'MonitoringConfigOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_addons_operations.py index 86490d757f0c..2ef2fd17c600 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_addons_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,109 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._addons_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_role_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AddonsOperations: - """AddonsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`addons` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_role( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AddonList"]: + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Addon"]: """Lists all the addons configured in the role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AddonList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_role.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -116,76 +154,81 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_role.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + @distributed_trace_async async def get( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Addon": + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: """Gets a specific addon by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } async def _create_or_update_initial( self, @@ -193,43 +236,55 @@ async def _create_or_update_initial( role_name: str, addon_name: str, resource_group_name: str, - addon: "_models.Addon", - **kwargs - ) -> Optional["_models.Addon"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Addon"]] + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(addon, 'Addon') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -238,52 +293,148 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload async def begin_create_or_update( self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, - addon: "_models.Addon", - **kwargs - ) -> AsyncLROPoller["_models.Addon"]: + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: """Create or update a addon. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param addon: The addon properties. + :param addon: The addon properties. Required. :type addon: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Addon or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -291,79 +442,77 @@ async def begin_create_or_update( addon_name=addon_name, resource_group_name=resource_group_name, addon=addon, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -373,78 +522,81 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the addon on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, addon_name=addon_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_alerts_operations.py index 1df491e86495..aeb113b13902 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._alerts_operations import build_get_request, build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AlertsOperations: - """AlertsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AlertList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,71 +144,75 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Alert": + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_available_skus_operations.py index 4e0b2b5bcddf..e403a1fc33d9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,129 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._available_skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AvailableSkusOperations: - """AvailableSkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeSkuList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +137,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_bandwidth_schedules_operations.py index 8885812017bd..d60ac23df5d5 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._bandwidth_schedules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BandwidthSchedulesOperations: - """BandwidthSchedulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.BandwidthSchedulesList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +151,132 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.BandwidthSchedule": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> Optional["_models.BandwidthSchedule"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +285,219 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> AsyncLROPoller["_models.BandwidthSchedule"]: + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +507,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_containers_operations.py index 0d8b3454251d..5e315ec6f341 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,149 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._containers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_storage_account_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainersOperations: - """ContainersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_storage_account( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ContainerList"]: + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,78 +157,83 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Container": + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } async def _create_or_update_initial( self, @@ -197,43 +241,55 @@ async def _create_or_update_initial( storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> Optional["_models.Container"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -242,54 +298,157 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> AsyncLROPoller["_models.Container"]: + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Container or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -297,79 +456,77 @@ async def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -379,119 +536,120 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -501,80 +659,81 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_devices_operations.py index 52cdbc54ff00..6ebd1a9445d7 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,154 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._devices_operations import ( + build_create_or_update_request, + build_create_or_update_security_settings_request, + build_delete_request, + build_download_updates_request, + build_generate_certificate_request, + build_get_extended_information_request, + build_get_network_settings_request, + build_get_request, + build_get_update_summary_request, + build_install_updates_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_scan_for_updates_request, + build_update_extended_information_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations: - """DevicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_subscription( - self, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,74 +162,92 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,226 +256,335 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDevice": + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } async def _create_or_update_initial( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> "_models.DataBoxEdgeDevice": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> AsyncLROPoller["_models.DataBoxEdgeDevice"]: + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. - :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -415,171 +594,250 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload async def update( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDevicePatch", - **kwargs - ) -> "_models.DataBoxEdgeDevice": + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevicePatch or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - async def _download_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -589,223 +847,242 @@ async def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def begin_download_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._download_updates_initial( + raw_result = await self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def generate_certificate( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.GenerateCertResponse": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: """Generates certificate for activation key. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenerateCertResponse, or the result of cls(response) + :return: GenerateCertResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.GenerateCertResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCertResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.generate_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateCertResponse', pipeline_response) + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate'} # type: ignore + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace_async async def get_extended_information( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - async def _install_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + async def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -815,165 +1092,178 @@ async def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def begin_install_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._install_updates_initial( + raw_result = await self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def get_network_settings( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.NetworkSettings": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - async def _scan_for_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + async def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -983,113 +1273,130 @@ async def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + @distributed_trace_async async def begin_scan_for_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._scan_for_updates_initial( + raw_result = await self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - async def _create_or_update_security_settings_initial( + async def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1099,265 +1406,504 @@ async def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload async def begin_create_or_update_security_settings( self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SecuritySettings or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_security_settings_initial( + raw_result = await self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload async def update_extended_information( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDeviceExtendedInfoPatch", - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The patch object. - :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch + :param parameters: The patch object. Required. + :type parameters: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDeviceExtendedInfoPatch') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation'} # type: ignore + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace_async async def get_update_summary( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.UpdateSummary": - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload async def upload_certificate( self, device_name: str, resource_group_name: str, - parameters: "_models.UploadCertificateRequest", - **kwargs - ) -> "_models.UploadCertificateResponse": + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_jobs_operations.py index 8d1ef9d46a12..06d42c81baa5 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class JobsOperations: - """JobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_monitoring_config_operations.py index 01e65834f526..e5eb8b2f55e8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_monitoring_config_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_monitoring_config_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,149 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._monitoring_config_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringConfigOperations: - """MonitoringConfigOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.MonitoringMetricConfigurationList"]: + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MonitoringMetricConfiguration"]: """Lists metric configurations in a role. Lists metric configurations in a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 MonitoringMetricConfigurationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfigurationList', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,116 +157,134 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + + @distributed_trace_async async def get( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.MonitoringMetricConfiguration": + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: """Gets a metric configuration of a role. Gets a metric configuration of a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringMetricConfiguration, or the result of cls(response) + :return: MonitoringMetricConfiguration or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } async def _create_or_update_initial( self, device_name: str, role_name: str, resource_group_name: str, - monitoring_metric_configuration: "_models.MonitoringMetricConfiguration", - **kwargs - ) -> Optional["_models.MonitoringMetricConfiguration"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MonitoringMetricConfiguration"]] + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(monitoring_metric_configuration, 'MonitoringMetricConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -236,127 +293,227 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async async def begin_create_or_update( self, device_name: str, role_name: str, resource_group_name: str, - monitoring_metric_configuration: "_models.MonitoringMetricConfiguration", - **kwargs - ) -> AsyncLROPoller["_models.MonitoringMetricConfiguration"]: + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: """Creates a new metric configuration or updates an existing one for a role. Creates a new metric configuration or updates an existing one for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param monitoring_metric_configuration: The metric configuration. - :type monitoring_metric_configuration: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, monitoring_metric_configuration=monitoring_metric_configuration, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) - + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -366,75 +523,78 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """deletes a new metric configuration for a role. deletes a new metric configuration for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_nodes_operations.py index 16b1502c3c01..f15f579c68cd 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._nodes_operations import build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NodesOperations: - """NodesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.NodeList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +143,8 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_operations.py index e95f2b13a318..1c4fa9db5ce8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.OperationsList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +136,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_operations_status_operations.py index 950f863461ed..1cc4290be3d7 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations_status_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsStatusOperations: - """OperationsStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_orders_operations.py index 1e665d55ec85..909219a44a54 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._orders_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_list_dc_access_code_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OrdersOperations: - """OrdersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.OrderList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,110 +154,123 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Order": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } async def _create_or_update_initial( - self, - device_name: str, - resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> Optional["_models.Order"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -226,120 +279,207 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> AsyncLROPoller["_models.Order"]: + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Order or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -349,130 +489,139 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace_async async def list_dc_access_code( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DCAccessCode": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DCAccessCode: """Gets the DCAccess Code. Gets the DCAccess Code. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DCAccessCode, or the result of cls(response) + :return: DCAccessCode or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DCAccessCode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DCAccessCode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_dc_access_code.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DCAccessCode', pipeline_response) + deserialized = self._deserialize("DCAccessCode", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_dc_access_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode'} # type: ignore + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_roles_operations.py index 6b88bc8be448..cf39985130b6 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._roles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RolesOperations: - """RolesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.RoleList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +151,125 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Role": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> Optional["_models.Role"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +278,210 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> AsyncLROPoller["_models.Role"]: + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Role or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +491,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_shares_operations.py index d70a74348b59..62f718b230fa 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._shares_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SharesOperations: - """SharesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ShareList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +154,127 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Share": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> Optional["_models.Share"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +283,216 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> AsyncLROPoller["_models.Share"]: + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Share or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,112 +502,116 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -477,75 +621,78 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_storage_account_credentials_operations.py index 40c4cd4f3593..ba29e307a6ed 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_account_credentials_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountCredentialsOperations: - """StorageAccountCredentialsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountCredentialList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,114 +154,132 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccountCredential": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> Optional["_models.StorageAccountCredential"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -230,125 +288,221 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccountCredential"]: + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,73 +512,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_storage_accounts_operations.py index 188f3555a9cd..e2b24727517e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_accounts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountsOperations: - """StorageAccountsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +153,134 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccount": + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } async def _create_or_update_initial( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +289,225 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccount"]: + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -362,73 +517,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_triggers_operations.py index ed62fda82f71..c4da397763ee 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._triggers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TriggersOperations: - """TriggersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.TriggerList"]: + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +155,125 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Trigger": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> Optional["_models.Trigger"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,125 +282,213 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> AsyncLROPoller["_models.Trigger"]: + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Trigger or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Trigger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +498,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_users_operations.py index f3eee3cf5521..dc7938874e52 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/aio/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,148 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UsersOperations: - """UsersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.UserList"]: + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +156,125 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.User": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - user: "_models.User", - **kwargs - ) -> Optional["_models.User"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,126 +283,213 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - user: "_models.User", - **kwargs - ) -> AsyncLROPoller["_models.User"]: + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -363,73 +499,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/__init__.py index 8b331ada40a8..52dfb236f5e9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/__init__.py @@ -6,471 +6,356 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARMBaseModel - from ._models_py3 import Addon - from ._models_py3 import AddonList - from ._models_py3 import Address - from ._models_py3 import Alert - from ._models_py3 import AlertErrorDetails - from ._models_py3 import AlertList - from ._models_py3 import ArcAddon - from ._models_py3 import AsymmetricEncryptedSecret - from ._models_py3 import Authentication - from ._models_py3 import AzureContainerInfo - from ._models_py3 import BandwidthSchedule - from ._models_py3 import BandwidthSchedulesList - from ._models_py3 import ClientAccessRight - from ._models_py3 import CloudEdgeManagementRole - from ._models_py3 import CloudErrorBody - from ._models_py3 import CniConfig - from ._models_py3 import ComputeResource - from ._models_py3 import ContactDetails - from ._models_py3 import Container - from ._models_py3 import ContainerList - from ._models_py3 import DCAccessCode - from ._models_py3 import DataBoxEdgeDevice - from ._models_py3 import DataBoxEdgeDeviceExtendedInfo - from ._models_py3 import DataBoxEdgeDeviceExtendedInfoPatch - from ._models_py3 import DataBoxEdgeDeviceList - from ._models_py3 import DataBoxEdgeDevicePatch - from ._models_py3 import DataBoxEdgeMoveRequest - from ._models_py3 import DataBoxEdgeSku - from ._models_py3 import DataBoxEdgeSkuList - from ._models_py3 import EdgeProfile - from ._models_py3 import EdgeProfilePatch - from ._models_py3 import EdgeProfileSubscription - from ._models_py3 import EdgeProfileSubscriptionPatch - from ._models_py3 import EtcdInfo - from ._models_py3 import FileEventTrigger - from ._models_py3 import FileSourceInfo - from ._models_py3 import GenerateCertResponse - from ._models_py3 import ImageRepositoryCredential - from ._models_py3 import IoTAddon - from ._models_py3 import IoTDeviceInfo - from ._models_py3 import IoTEdgeAgentInfo - from ._models_py3 import IoTRole - from ._models_py3 import Ipv4Config - from ._models_py3 import Ipv6Config - from ._models_py3 import Job - from ._models_py3 import JobErrorDetails - from ._models_py3 import JobErrorItem - from ._models_py3 import KubernetesClusterInfo - from ._models_py3 import KubernetesIPConfiguration - from ._models_py3 import KubernetesRole - from ._models_py3 import KubernetesRoleCompute - from ._models_py3 import KubernetesRoleNetwork - from ._models_py3 import KubernetesRoleResources - from ._models_py3 import KubernetesRoleStorage - from ._models_py3 import KubernetesRoleStorageClassInfo - from ._models_py3 import LoadBalancerConfig - from ._models_py3 import MECRole - from ._models_py3 import MetricConfiguration - from ._models_py3 import MetricCounter - from ._models_py3 import MetricCounterSet - from ._models_py3 import MetricDimension - from ._models_py3 import MetricDimensionV1 - from ._models_py3 import MetricSpecificationV1 - from ._models_py3 import MonitoringMetricConfiguration - from ._models_py3 import MonitoringMetricConfigurationList - from ._models_py3 import MountPointMap - from ._models_py3 import NetworkAdapter - from ._models_py3 import NetworkAdapterPosition - from ._models_py3 import NetworkSettings - from ._models_py3 import Node - from ._models_py3 import NodeInfo - from ._models_py3 import NodeList - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import Order - from ._models_py3 import OrderList - from ._models_py3 import OrderStatus - from ._models_py3 import PeriodicTimerEventTrigger - from ._models_py3 import PeriodicTimerSourceInfo - from ._models_py3 import RefreshDetails - from ._models_py3 import ResourceIdentity - from ._models_py3 import ResourceMoveDetails - from ._models_py3 import ResourceTypeSku - from ._models_py3 import Role - from ._models_py3 import RoleList - from ._models_py3 import RoleSinkInfo - from ._models_py3 import SecuritySettings - from ._models_py3 import ServiceSpecification - from ._models_py3 import Share - from ._models_py3 import ShareAccessRight - from ._models_py3 import ShareList - from ._models_py3 import Sku - from ._models_py3 import SkuCost - from ._models_py3 import SkuInformation - from ._models_py3 import SkuInformationList - from ._models_py3 import SkuLocationInfo - from ._models_py3 import StorageAccount - from ._models_py3 import StorageAccountCredential - from ._models_py3 import StorageAccountCredentialList - from ._models_py3 import StorageAccountList - from ._models_py3 import SubscriptionRegisteredFeatures - from ._models_py3 import SymmetricKey - from ._models_py3 import SystemData - from ._models_py3 import TrackingInfo - from ._models_py3 import Trigger - from ._models_py3 import TriggerList - from ._models_py3 import UpdateDownloadProgress - from ._models_py3 import UpdateInstallProgress - from ._models_py3 import UpdateSummary - from ._models_py3 import UploadCertificateRequest - from ._models_py3 import UploadCertificateResponse - from ._models_py3 import User - from ._models_py3 import UserAccessRight - from ._models_py3 import UserList -except (SyntaxError, ImportError): - from ._models import ARMBaseModel # type: ignore - from ._models import Addon # type: ignore - from ._models import AddonList # type: ignore - from ._models import Address # type: ignore - from ._models import Alert # type: ignore - from ._models import AlertErrorDetails # type: ignore - from ._models import AlertList # type: ignore - from ._models import ArcAddon # type: ignore - from ._models import AsymmetricEncryptedSecret # type: ignore - from ._models import Authentication # type: ignore - from ._models import AzureContainerInfo # type: ignore - from ._models import BandwidthSchedule # type: ignore - from ._models import BandwidthSchedulesList # type: ignore - from ._models import ClientAccessRight # type: ignore - from ._models import CloudEdgeManagementRole # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import CniConfig # type: ignore - from ._models import ComputeResource # type: ignore - from ._models import ContactDetails # type: ignore - from ._models import Container # type: ignore - from ._models import ContainerList # type: ignore - from ._models import DCAccessCode # type: ignore - from ._models import DataBoxEdgeDevice # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfo # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfoPatch # type: ignore - from ._models import DataBoxEdgeDeviceList # type: ignore - from ._models import DataBoxEdgeDevicePatch # type: ignore - from ._models import DataBoxEdgeMoveRequest # type: ignore - from ._models import DataBoxEdgeSku # type: ignore - from ._models import DataBoxEdgeSkuList # type: ignore - from ._models import EdgeProfile # type: ignore - from ._models import EdgeProfilePatch # type: ignore - from ._models import EdgeProfileSubscription # type: ignore - from ._models import EdgeProfileSubscriptionPatch # type: ignore - from ._models import EtcdInfo # type: ignore - from ._models import FileEventTrigger # type: ignore - from ._models import FileSourceInfo # type: ignore - from ._models import GenerateCertResponse # type: ignore - from ._models import ImageRepositoryCredential # type: ignore - from ._models import IoTAddon # type: ignore - from ._models import IoTDeviceInfo # type: ignore - from ._models import IoTEdgeAgentInfo # type: ignore - from ._models import IoTRole # type: ignore - from ._models import Ipv4Config # type: ignore - from ._models import Ipv6Config # type: ignore - from ._models import Job # type: ignore - from ._models import JobErrorDetails # type: ignore - from ._models import JobErrorItem # type: ignore - from ._models import KubernetesClusterInfo # type: ignore - from ._models import KubernetesIPConfiguration # type: ignore - from ._models import KubernetesRole # type: ignore - from ._models import KubernetesRoleCompute # type: ignore - from ._models import KubernetesRoleNetwork # type: ignore - from ._models import KubernetesRoleResources # type: ignore - from ._models import KubernetesRoleStorage # type: ignore - from ._models import KubernetesRoleStorageClassInfo # type: ignore - from ._models import LoadBalancerConfig # type: ignore - from ._models import MECRole # type: ignore - from ._models import MetricConfiguration # type: ignore - from ._models import MetricCounter # type: ignore - from ._models import MetricCounterSet # type: ignore - from ._models import MetricDimension # type: ignore - from ._models import MetricDimensionV1 # type: ignore - from ._models import MetricSpecificationV1 # type: ignore - from ._models import MonitoringMetricConfiguration # type: ignore - from ._models import MonitoringMetricConfigurationList # type: ignore - from ._models import MountPointMap # type: ignore - from ._models import NetworkAdapter # type: ignore - from ._models import NetworkAdapterPosition # type: ignore - from ._models import NetworkSettings # type: ignore - from ._models import Node # type: ignore - from ._models import NodeInfo # type: ignore - from ._models import NodeList # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import Order # type: ignore - from ._models import OrderList # type: ignore - from ._models import OrderStatus # type: ignore - from ._models import PeriodicTimerEventTrigger # type: ignore - from ._models import PeriodicTimerSourceInfo # type: ignore - from ._models import RefreshDetails # type: ignore - from ._models import ResourceIdentity # type: ignore - from ._models import ResourceMoveDetails # type: ignore - from ._models import ResourceTypeSku # type: ignore - from ._models import Role # type: ignore - from ._models import RoleList # type: ignore - from ._models import RoleSinkInfo # type: ignore - from ._models import SecuritySettings # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Share # type: ignore - from ._models import ShareAccessRight # type: ignore - from ._models import ShareList # type: ignore - from ._models import Sku # type: ignore - from ._models import SkuCost # type: ignore - from ._models import SkuInformation # type: ignore - from ._models import SkuInformationList # type: ignore - from ._models import SkuLocationInfo # type: ignore - from ._models import StorageAccount # type: ignore - from ._models import StorageAccountCredential # type: ignore - from ._models import StorageAccountCredentialList # type: ignore - from ._models import StorageAccountList # type: ignore - from ._models import SubscriptionRegisteredFeatures # type: ignore - from ._models import SymmetricKey # type: ignore - from ._models import SystemData # type: ignore - from ._models import TrackingInfo # type: ignore - from ._models import Trigger # type: ignore - from ._models import TriggerList # type: ignore - from ._models import UpdateDownloadProgress # type: ignore - from ._models import UpdateInstallProgress # type: ignore - from ._models import UpdateSummary # type: ignore - from ._models import UploadCertificateRequest # type: ignore - from ._models import UploadCertificateResponse # type: ignore - from ._models import User # type: ignore - from ._models import UserAccessRight # type: ignore - from ._models import UserList # type: ignore +from ._models_py3 import ARMBaseModel +from ._models_py3 import Addon +from ._models_py3 import AddonList +from ._models_py3 import Address +from ._models_py3 import Alert +from ._models_py3 import AlertErrorDetails +from ._models_py3 import AlertList +from ._models_py3 import ArcAddon +from ._models_py3 import AsymmetricEncryptedSecret +from ._models_py3 import Authentication +from ._models_py3 import AzureContainerInfo +from ._models_py3 import BandwidthSchedule +from ._models_py3 import BandwidthSchedulesList +from ._models_py3 import ClientAccessRight +from ._models_py3 import CloudEdgeManagementRole +from ._models_py3 import CloudErrorBody +from ._models_py3 import CniConfig +from ._models_py3 import ComputeResource +from ._models_py3 import ContactDetails +from ._models_py3 import Container +from ._models_py3 import ContainerList +from ._models_py3 import DCAccessCode +from ._models_py3 import DataBoxEdgeDevice +from ._models_py3 import DataBoxEdgeDeviceExtendedInfo +from ._models_py3 import DataBoxEdgeDeviceExtendedInfoPatch +from ._models_py3 import DataBoxEdgeDeviceList +from ._models_py3 import DataBoxEdgeDevicePatch +from ._models_py3 import DataBoxEdgeMoveRequest +from ._models_py3 import DataBoxEdgeSku +from ._models_py3 import DataBoxEdgeSkuList +from ._models_py3 import EdgeProfile +from ._models_py3 import EdgeProfilePatch +from ._models_py3 import EdgeProfileSubscription +from ._models_py3 import EdgeProfileSubscriptionPatch +from ._models_py3 import EtcdInfo +from ._models_py3 import FileEventTrigger +from ._models_py3 import FileSourceInfo +from ._models_py3 import GenerateCertResponse +from ._models_py3 import ImageRepositoryCredential +from ._models_py3 import IoTAddon +from ._models_py3 import IoTDeviceInfo +from ._models_py3 import IoTEdgeAgentInfo +from ._models_py3 import IoTRole +from ._models_py3 import Ipv4Config +from ._models_py3 import Ipv6Config +from ._models_py3 import Job +from ._models_py3 import JobErrorDetails +from ._models_py3 import JobErrorItem +from ._models_py3 import KubernetesClusterInfo +from ._models_py3 import KubernetesIPConfiguration +from ._models_py3 import KubernetesRole +from ._models_py3 import KubernetesRoleCompute +from ._models_py3 import KubernetesRoleNetwork +from ._models_py3 import KubernetesRoleResources +from ._models_py3 import KubernetesRoleStorage +from ._models_py3 import KubernetesRoleStorageClassInfo +from ._models_py3 import LoadBalancerConfig +from ._models_py3 import MECRole +from ._models_py3 import MetricConfiguration +from ._models_py3 import MetricCounter +from ._models_py3 import MetricCounterSet +from ._models_py3 import MetricDimension +from ._models_py3 import MetricDimensionV1 +from ._models_py3 import MetricSpecificationV1 +from ._models_py3 import MonitoringMetricConfiguration +from ._models_py3 import MonitoringMetricConfigurationList +from ._models_py3 import MountPointMap +from ._models_py3 import NetworkAdapter +from ._models_py3 import NetworkAdapterPosition +from ._models_py3 import NetworkSettings +from ._models_py3 import Node +from ._models_py3 import NodeInfo +from ._models_py3 import NodeList +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import Order +from ._models_py3 import OrderList +from ._models_py3 import OrderStatus +from ._models_py3 import PeriodicTimerEventTrigger +from ._models_py3 import PeriodicTimerSourceInfo +from ._models_py3 import RefreshDetails +from ._models_py3 import ResourceIdentity +from ._models_py3 import ResourceMoveDetails +from ._models_py3 import ResourceTypeSku +from ._models_py3 import Role +from ._models_py3 import RoleList +from ._models_py3 import RoleSinkInfo +from ._models_py3 import SecuritySettings +from ._models_py3 import ServiceSpecification +from ._models_py3 import Share +from ._models_py3 import ShareAccessRight +from ._models_py3 import ShareList +from ._models_py3 import Sku +from ._models_py3 import SkuCost +from ._models_py3 import SkuInformation +from ._models_py3 import SkuInformationList +from ._models_py3 import SkuLocationInfo +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCredential +from ._models_py3 import StorageAccountCredentialList +from ._models_py3 import StorageAccountList +from ._models_py3 import SubscriptionRegisteredFeatures +from ._models_py3 import SymmetricKey +from ._models_py3 import SystemData +from ._models_py3 import TrackingInfo +from ._models_py3 import Trigger +from ._models_py3 import TriggerList +from ._models_py3 import UpdateDownloadProgress +from ._models_py3 import UpdateInstallProgress +from ._models_py3 import UpdateSummary +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UploadCertificateResponse +from ._models_py3 import User +from ._models_py3 import UserAccessRight +from ._models_py3 import UserList -from ._data_box_edge_management_client_enums import ( - AccountType, - AddonState, - AddonType, - AlertSeverity, - AuthenticationType, - AzureContainerDataFormat, - ClientPermissionType, - ContainerStatus, - CreatedByType, - DataBoxEdgeDeviceKind, - DataBoxEdgeDeviceStatus, - DataPolicy, - DayOfWeek, - DeviceType, - DownloadPhase, - EncryptionAlgorithm, - HostPlatformType, - InstallRebootBehavior, - JobStatus, - JobType, - KubernetesNodeType, - KubernetesState, - MetricAggregationType, - MetricCategory, - MetricUnit, - MonitoringStatus, - MountType, - MsiIdentityType, - NetworkAdapterDHCPStatus, - NetworkAdapterRDMAStatus, - NetworkAdapterStatus, - NetworkGroup, - NodeStatus, - OrderState, - PlatformType, - PosixComplianceStatus, - ResourceMoveStatus, - RoleStatus, - RoleTypes, - SSLStatus, - ShareAccessProtocol, - ShareAccessType, - ShareStatus, - ShipmentType, - SkuAvailability, - SkuName, - SkuSignupOption, - SkuTier, - SkuVersion, - StorageAccountStatus, - SubscriptionState, - TimeGrain, - TriggerEventType, - UpdateOperation, - UpdateOperationStage, - UserType, -) +from ._data_box_edge_management_client_enums import AccountType +from ._data_box_edge_management_client_enums import AddonState +from ._data_box_edge_management_client_enums import AddonType +from ._data_box_edge_management_client_enums import AlertSeverity +from ._data_box_edge_management_client_enums import AuthenticationType +from ._data_box_edge_management_client_enums import AzureContainerDataFormat +from ._data_box_edge_management_client_enums import ClientPermissionType +from ._data_box_edge_management_client_enums import ContainerStatus +from ._data_box_edge_management_client_enums import CreatedByType +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceKind +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceStatus +from ._data_box_edge_management_client_enums import DataPolicy +from ._data_box_edge_management_client_enums import DayOfWeek +from ._data_box_edge_management_client_enums import DeviceType +from ._data_box_edge_management_client_enums import DownloadPhase +from ._data_box_edge_management_client_enums import EncryptionAlgorithm +from ._data_box_edge_management_client_enums import HostPlatformType +from ._data_box_edge_management_client_enums import InstallRebootBehavior +from ._data_box_edge_management_client_enums import JobStatus +from ._data_box_edge_management_client_enums import JobType +from ._data_box_edge_management_client_enums import KubernetesNodeType +from ._data_box_edge_management_client_enums import KubernetesState +from ._data_box_edge_management_client_enums import MetricAggregationType +from ._data_box_edge_management_client_enums import MetricCategory +from ._data_box_edge_management_client_enums import MetricUnit +from ._data_box_edge_management_client_enums import MonitoringStatus +from ._data_box_edge_management_client_enums import MountType +from ._data_box_edge_management_client_enums import MsiIdentityType +from ._data_box_edge_management_client_enums import NetworkAdapterDHCPStatus +from ._data_box_edge_management_client_enums import NetworkAdapterRDMAStatus +from ._data_box_edge_management_client_enums import NetworkAdapterStatus +from ._data_box_edge_management_client_enums import NetworkGroup +from ._data_box_edge_management_client_enums import NodeStatus +from ._data_box_edge_management_client_enums import OrderState +from ._data_box_edge_management_client_enums import PlatformType +from ._data_box_edge_management_client_enums import PosixComplianceStatus +from ._data_box_edge_management_client_enums import ResourceMoveStatus +from ._data_box_edge_management_client_enums import RoleStatus +from ._data_box_edge_management_client_enums import RoleTypes +from ._data_box_edge_management_client_enums import SSLStatus +from ._data_box_edge_management_client_enums import ShareAccessProtocol +from ._data_box_edge_management_client_enums import ShareAccessType +from ._data_box_edge_management_client_enums import ShareStatus +from ._data_box_edge_management_client_enums import ShipmentType +from ._data_box_edge_management_client_enums import SkuAvailability +from ._data_box_edge_management_client_enums import SkuName +from ._data_box_edge_management_client_enums import SkuSignupOption +from ._data_box_edge_management_client_enums import SkuTier +from ._data_box_edge_management_client_enums import SkuVersion +from ._data_box_edge_management_client_enums import StorageAccountStatus +from ._data_box_edge_management_client_enums import SubscriptionState +from ._data_box_edge_management_client_enums import TimeGrain +from ._data_box_edge_management_client_enums import TriggerEventType +from ._data_box_edge_management_client_enums import UpdateOperation +from ._data_box_edge_management_client_enums import UpdateOperationStage +from ._data_box_edge_management_client_enums import UserType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ARMBaseModel', - 'Addon', - 'AddonList', - 'Address', - 'Alert', - 'AlertErrorDetails', - 'AlertList', - 'ArcAddon', - 'AsymmetricEncryptedSecret', - 'Authentication', - 'AzureContainerInfo', - 'BandwidthSchedule', - 'BandwidthSchedulesList', - 'ClientAccessRight', - 'CloudEdgeManagementRole', - 'CloudErrorBody', - 'CniConfig', - 'ComputeResource', - 'ContactDetails', - 'Container', - 'ContainerList', - 'DCAccessCode', - 'DataBoxEdgeDevice', - 'DataBoxEdgeDeviceExtendedInfo', - 'DataBoxEdgeDeviceExtendedInfoPatch', - 'DataBoxEdgeDeviceList', - 'DataBoxEdgeDevicePatch', - 'DataBoxEdgeMoveRequest', - 'DataBoxEdgeSku', - 'DataBoxEdgeSkuList', - 'EdgeProfile', - 'EdgeProfilePatch', - 'EdgeProfileSubscription', - 'EdgeProfileSubscriptionPatch', - 'EtcdInfo', - 'FileEventTrigger', - 'FileSourceInfo', - 'GenerateCertResponse', - 'ImageRepositoryCredential', - 'IoTAddon', - 'IoTDeviceInfo', - 'IoTEdgeAgentInfo', - 'IoTRole', - 'Ipv4Config', - 'Ipv6Config', - 'Job', - 'JobErrorDetails', - 'JobErrorItem', - 'KubernetesClusterInfo', - 'KubernetesIPConfiguration', - 'KubernetesRole', - 'KubernetesRoleCompute', - 'KubernetesRoleNetwork', - 'KubernetesRoleResources', - 'KubernetesRoleStorage', - 'KubernetesRoleStorageClassInfo', - 'LoadBalancerConfig', - 'MECRole', - 'MetricConfiguration', - 'MetricCounter', - 'MetricCounterSet', - 'MetricDimension', - 'MetricDimensionV1', - 'MetricSpecificationV1', - 'MonitoringMetricConfiguration', - 'MonitoringMetricConfigurationList', - 'MountPointMap', - 'NetworkAdapter', - 'NetworkAdapterPosition', - 'NetworkSettings', - 'Node', - 'NodeInfo', - 'NodeList', - 'Operation', - 'OperationDisplay', - 'OperationsList', - 'Order', - 'OrderList', - 'OrderStatus', - 'PeriodicTimerEventTrigger', - 'PeriodicTimerSourceInfo', - 'RefreshDetails', - 'ResourceIdentity', - 'ResourceMoveDetails', - 'ResourceTypeSku', - 'Role', - 'RoleList', - 'RoleSinkInfo', - 'SecuritySettings', - 'ServiceSpecification', - 'Share', - 'ShareAccessRight', - 'ShareList', - 'Sku', - 'SkuCost', - 'SkuInformation', - 'SkuInformationList', - 'SkuLocationInfo', - 'StorageAccount', - 'StorageAccountCredential', - 'StorageAccountCredentialList', - 'StorageAccountList', - 'SubscriptionRegisteredFeatures', - 'SymmetricKey', - 'SystemData', - 'TrackingInfo', - 'Trigger', - 'TriggerList', - 'UpdateDownloadProgress', - 'UpdateInstallProgress', - 'UpdateSummary', - 'UploadCertificateRequest', - 'UploadCertificateResponse', - 'User', - 'UserAccessRight', - 'UserList', - 'AccountType', - 'AddonState', - 'AddonType', - 'AlertSeverity', - 'AuthenticationType', - 'AzureContainerDataFormat', - 'ClientPermissionType', - 'ContainerStatus', - 'CreatedByType', - 'DataBoxEdgeDeviceKind', - 'DataBoxEdgeDeviceStatus', - 'DataPolicy', - 'DayOfWeek', - 'DeviceType', - 'DownloadPhase', - 'EncryptionAlgorithm', - 'HostPlatformType', - 'InstallRebootBehavior', - 'JobStatus', - 'JobType', - 'KubernetesNodeType', - 'KubernetesState', - 'MetricAggregationType', - 'MetricCategory', - 'MetricUnit', - 'MonitoringStatus', - 'MountType', - 'MsiIdentityType', - 'NetworkAdapterDHCPStatus', - 'NetworkAdapterRDMAStatus', - 'NetworkAdapterStatus', - 'NetworkGroup', - 'NodeStatus', - 'OrderState', - 'PlatformType', - 'PosixComplianceStatus', - 'ResourceMoveStatus', - 'RoleStatus', - 'RoleTypes', - 'SSLStatus', - 'ShareAccessProtocol', - 'ShareAccessType', - 'ShareStatus', - 'ShipmentType', - 'SkuAvailability', - 'SkuName', - 'SkuSignupOption', - 'SkuTier', - 'SkuVersion', - 'StorageAccountStatus', - 'SubscriptionState', - 'TimeGrain', - 'TriggerEventType', - 'UpdateOperation', - 'UpdateOperationStage', - 'UserType', + "ARMBaseModel", + "Addon", + "AddonList", + "Address", + "Alert", + "AlertErrorDetails", + "AlertList", + "ArcAddon", + "AsymmetricEncryptedSecret", + "Authentication", + "AzureContainerInfo", + "BandwidthSchedule", + "BandwidthSchedulesList", + "ClientAccessRight", + "CloudEdgeManagementRole", + "CloudErrorBody", + "CniConfig", + "ComputeResource", + "ContactDetails", + "Container", + "ContainerList", + "DCAccessCode", + "DataBoxEdgeDevice", + "DataBoxEdgeDeviceExtendedInfo", + "DataBoxEdgeDeviceExtendedInfoPatch", + "DataBoxEdgeDeviceList", + "DataBoxEdgeDevicePatch", + "DataBoxEdgeMoveRequest", + "DataBoxEdgeSku", + "DataBoxEdgeSkuList", + "EdgeProfile", + "EdgeProfilePatch", + "EdgeProfileSubscription", + "EdgeProfileSubscriptionPatch", + "EtcdInfo", + "FileEventTrigger", + "FileSourceInfo", + "GenerateCertResponse", + "ImageRepositoryCredential", + "IoTAddon", + "IoTDeviceInfo", + "IoTEdgeAgentInfo", + "IoTRole", + "Ipv4Config", + "Ipv6Config", + "Job", + "JobErrorDetails", + "JobErrorItem", + "KubernetesClusterInfo", + "KubernetesIPConfiguration", + "KubernetesRole", + "KubernetesRoleCompute", + "KubernetesRoleNetwork", + "KubernetesRoleResources", + "KubernetesRoleStorage", + "KubernetesRoleStorageClassInfo", + "LoadBalancerConfig", + "MECRole", + "MetricConfiguration", + "MetricCounter", + "MetricCounterSet", + "MetricDimension", + "MetricDimensionV1", + "MetricSpecificationV1", + "MonitoringMetricConfiguration", + "MonitoringMetricConfigurationList", + "MountPointMap", + "NetworkAdapter", + "NetworkAdapterPosition", + "NetworkSettings", + "Node", + "NodeInfo", + "NodeList", + "Operation", + "OperationDisplay", + "OperationsList", + "Order", + "OrderList", + "OrderStatus", + "PeriodicTimerEventTrigger", + "PeriodicTimerSourceInfo", + "RefreshDetails", + "ResourceIdentity", + "ResourceMoveDetails", + "ResourceTypeSku", + "Role", + "RoleList", + "RoleSinkInfo", + "SecuritySettings", + "ServiceSpecification", + "Share", + "ShareAccessRight", + "ShareList", + "Sku", + "SkuCost", + "SkuInformation", + "SkuInformationList", + "SkuLocationInfo", + "StorageAccount", + "StorageAccountCredential", + "StorageAccountCredentialList", + "StorageAccountList", + "SubscriptionRegisteredFeatures", + "SymmetricKey", + "SystemData", + "TrackingInfo", + "Trigger", + "TriggerList", + "UpdateDownloadProgress", + "UpdateInstallProgress", + "UpdateSummary", + "UploadCertificateRequest", + "UploadCertificateResponse", + "User", + "UserAccessRight", + "UserList", + "AccountType", + "AddonState", + "AddonType", + "AlertSeverity", + "AuthenticationType", + "AzureContainerDataFormat", + "ClientPermissionType", + "ContainerStatus", + "CreatedByType", + "DataBoxEdgeDeviceKind", + "DataBoxEdgeDeviceStatus", + "DataPolicy", + "DayOfWeek", + "DeviceType", + "DownloadPhase", + "EncryptionAlgorithm", + "HostPlatformType", + "InstallRebootBehavior", + "JobStatus", + "JobType", + "KubernetesNodeType", + "KubernetesState", + "MetricAggregationType", + "MetricCategory", + "MetricUnit", + "MonitoringStatus", + "MountType", + "MsiIdentityType", + "NetworkAdapterDHCPStatus", + "NetworkAdapterRDMAStatus", + "NetworkAdapterStatus", + "NetworkGroup", + "NodeStatus", + "OrderState", + "PlatformType", + "PosixComplianceStatus", + "ResourceMoveStatus", + "RoleStatus", + "RoleTypes", + "SSLStatus", + "ShareAccessProtocol", + "ShareAccessType", + "ShareStatus", + "ShipmentType", + "SkuAvailability", + "SkuName", + "SkuSignupOption", + "SkuTier", + "SkuVersion", + "StorageAccountStatus", + "SubscriptionState", + "TimeGrain", + "TriggerEventType", + "UpdateOperation", + "UpdateOperationStage", + "UserType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_data_box_edge_management_client_enums.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_data_box_edge_management_client_enums.py index 0cec6392e961..8929fe116d25 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_data_box_edge_management_client_enums.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_data_box_edge_management_client_enums.py @@ -6,36 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of storage accessed on the storage account. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of storage accessed on the storage account.""" GENERAL_PURPOSE_STORAGE = "GeneralPurposeStorage" BLOB_STORAGE = "BlobStorage" -class AddonState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Addon Provisioning State - """ + +class AddonState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon Provisioning State.""" INVALID = "Invalid" CREATING = "Creating" @@ -45,47 +28,47 @@ class AddonState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETING = "Deleting" -class AddonType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Addon type. - """ + +class AddonType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon type.""" IOT_EDGE = "IotEdge" ARC_FOR_KUBERNETES = "ArcForKubernetes" -class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the alert. - """ + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert.""" INFORMATIONAL = "Informational" WARNING = "Warning" CRITICAL = "Critical" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The authentication type. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication type.""" INVALID = "Invalid" AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" -class AzureContainerDataFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Storage format used for the file represented by the share. - """ + +class AzureContainerDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage format used for the file represented by the share.""" BLOCK_BLOB = "BlockBlob" PAGE_BLOB = "PageBlob" AZURE_FILE = "AzureFile" -class ClientPermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed for the client. - """ + +class ClientPermissionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed for the client.""" NO_ACCESS = "NoAccess" READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the container. - """ + +class ContainerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the container.""" OK = "OK" OFFLINE = "Offline" @@ -93,27 +76,27 @@ class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DataBoxEdgeDeviceKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The etag for the devices. - """ + +class DataBoxEdgeDeviceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The etag for the devices.""" AZURE_DATA_BOX_GATEWAY = "AzureDataBoxGateway" AZURE_STACK_EDGE = "AzureStackEdge" AZURE_STACK_HUB = "AzureStackHub" AZURE_MODULAR_DATA_CENTRE = "AzureModularDataCentre" -class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the Data Box Edge/Gateway device. - """ + +class DataBoxEdgeDeviceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the Data Box Edge/Gateway device.""" READY_TO_SETUP = "ReadyToSetup" ONLINE = "Online" @@ -123,14 +106,16 @@ class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum PARTIALLY_DISCONNECTED = "PartiallyDisconnected" MAINTENANCE = "Maintenance" -class DataPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Data policy of the share. - """ + +class DataPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data policy of the share.""" CLOUD = "Cloud" LOCAL = "Local" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -140,47 +125,47 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DeviceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the Data Box Edge/Gateway device. - """ + +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the Data Box Edge/Gateway device.""" DATA_BOX_EDGE_DEVICE = "DataBoxEdgeDevice" -class DownloadPhase(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The download phase. - """ + +class DownloadPhase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The download phase.""" UNKNOWN = "Unknown" INITIALIZING = "Initializing" DOWNLOADING = "Downloading" VERIFYING = "Verifying" -class EncryptionAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The algorithm used to encrypt "Value". - """ + +class EncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The algorithm used to encrypt "Value".""" NONE = "None" AES256 = "AES256" RSAES_PKCS1_V1_5 = "RSAES_PKCS1_v_1_5" -class HostPlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Platform where the runtime is hosted. - """ + +class HostPlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Platform where the runtime is hosted.""" KUBERNETES_CLUSTER = "KubernetesCluster" LINUX_VM = "LinuxVM" -class InstallRebootBehavior(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if updates are available and at least one of the updates needs a reboot. - """ + +class InstallRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if updates are available and at least one of the updates needs a reboot.""" NEVER_REBOOTS = "NeverReboots" REQUIRES_REBOOT = "RequiresReboot" REQUEST_REBOOT = "RequestReboot" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the job.""" INVALID = "Invalid" RUNNING = "Running" @@ -190,9 +175,9 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PAUSED = "Paused" SCHEDULED = "Scheduled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" INVALID = "Invalid" SCAN_FOR_UPDATES = "ScanForUpdates" @@ -204,17 +189,17 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESTORE = "Restore" TRIGGER_SUPPORT_PACKAGE = "TriggerSupportPackage" -class KubernetesNodeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Node type - Master/Worker - """ + +class KubernetesNodeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Node type - Master/Worker.""" INVALID = "Invalid" MASTER = "Master" WORKER = "Worker" -class KubernetesState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """State of Kubernetes deployment - """ + +class KubernetesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of Kubernetes deployment.""" INVALID = "Invalid" CREATING = "Creating" @@ -224,9 +209,9 @@ class KubernetesState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETING = "Deleting" -class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric aggregation type. - """ + +class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric aggregation type.""" NOT_SPECIFIED = "NotSpecified" NONE = "None" @@ -236,16 +221,16 @@ class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) TOTAL = "Total" COUNT = "Count" -class MetricCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric category. - """ + +class MetricCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric category.""" CAPACITY = "Capacity" TRANSACTION = "Transaction" -class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric units. - """ + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric units.""" NOT_SPECIFIED = "NotSpecified" PERCENT = "Percent" @@ -256,60 +241,60 @@ class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BYTES_PER_SECOND = "BytesPerSecond" COUNT_PER_SECOND = "CountPerSecond" -class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current monitoring status of the share. - """ + +class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current monitoring status of the share.""" ENABLED = "Enabled" DISABLED = "Disabled" -class MountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Mounting type. - """ + +class MountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Mounting type.""" VOLUME = "Volume" HOST_PATH = "HostPath" -class MsiIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Identity type - """ + +class MsiIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" -class NetworkAdapterDHCPStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter has DHCP enabled. - """ + +class NetworkAdapterDHCPStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter has DHCP enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" -class NetworkAdapterRDMAStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is RDMA capable. - """ + +class NetworkAdapterRDMAStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is RDMA capable.""" INCAPABLE = "Incapable" CAPABLE = "Capable" -class NetworkAdapterStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is valid. - """ + +class NetworkAdapterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is valid.""" INACTIVE = "Inactive" ACTIVE = "Active" -class NetworkGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The network group. - """ + +class NetworkGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network group.""" NONE = "None" NON_RDMA = "NonRDMA" RDMA = "RDMA" -class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the individual node - """ + +class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the individual node.""" UNKNOWN = "Unknown" UP = "Up" @@ -317,9 +302,9 @@ class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REBOOTING = "Rebooting" SHUTTING_DOWN = "ShuttingDown" -class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the order as per the allowed status types. - """ + +class OrderState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the order as per the allowed status types.""" UNTRACKED = "Untracked" AWAITING_FULFILMENT = "AwaitingFulfilment" @@ -339,37 +324,39 @@ class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PICKUP_COMPLETED = "PickupCompleted" AWAITING_DROP = "AwaitingDrop" -class PlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Host OS supported by the Arc addon. - """ + +class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host OS supported by the Arc addon.""" WINDOWS = "Windows" LINUX = "Linux" -class PosixComplianceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """If provisioned storage is posix compliant. - """ + +class PosixComplianceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """If provisioned storage is posix compliant.""" INVALID = "Invalid" ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceMoveStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Denotes whether move operation is in progress - """ + +class ResourceMoveStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Denotes whether move operation is in progress.""" NONE = "None" RESOURCE_MOVE_IN_PROGRESS = "ResourceMoveInProgress" RESOURCE_MOVE_FAILED = "ResourceMoveFailed" -class RoleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Local Edge Management Status - """ + +class RoleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Local Edge Management Status.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RoleTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleTypes.""" IOT = "IOT" ASA = "ASA" @@ -379,24 +366,24 @@ class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CLOUD_EDGE_MANAGEMENT = "CloudEdgeManagement" KUBERNETES = "Kubernetes" -class ShareAccessProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Access protocol to be used by the share. - """ + +class ShareAccessProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access protocol to be used by the share.""" SMB = "SMB" NFS = "NFS" -class ShareAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed on the share for this user. - """ + +class ShareAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed on the share for this user.""" CHANGE = "Change" READ = "Read" CUSTOM = "Custom" -class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the share. - """ + +class ShareStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the share.""" OFFLINE = "Offline" UNKNOWN = "Unknown" @@ -404,22 +391,24 @@ class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class ShipmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class ShipmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ShipmentType.""" NOT_APPLICABLE = "NotApplicable" SHIPPED_TO_CUSTOMER = "ShippedToCustomer" SELF_PICKUP = "SelfPickup" -class SkuAvailability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Links to the next set of results - """ + +class SkuAvailability(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Links to the next set of results.""" AVAILABLE = "Available" UNAVAILABLE = "Unavailable" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku name. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku name.""" GATEWAY = "Gateway" EDGE = "Edge" @@ -443,36 +432,36 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RCA_LARGE = "RCA_Large" RDC = "RDC" -class SkuSignupOption(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Sku can be signed up by customer or not. - """ + +class SkuSignupOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sku can be signed up by customer or not.""" NONE = "None" AVAILABLE = "Available" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku tier. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku tier.""" STANDARD = "Standard" -class SkuVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Availability of the Sku as preview/stable. - """ + +class SkuVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Availability of the Sku as preview/stable.""" STABLE = "Stable" PREVIEW = "Preview" -class SSLStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Signifies whether SSL needs to be enabled or not. - """ + +class SSLStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Signifies whether SSL needs to be enabled or not.""" ENABLED = "Enabled" DISABLED = "Disabled" -class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the storage account - """ + +class StorageAccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the storage account.""" OK = "OK" OFFLINE = "Offline" @@ -480,7 +469,9 @@ class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SubscriptionState.""" REGISTERED = "Registered" WARNED = "Warned" @@ -488,7 +479,9 @@ class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETED = "Deleted" UNREGISTERED = "Unregistered" -class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class TimeGrain(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TimeGrain.""" PT1_M = "PT1M" PT5_M = "PT5M" @@ -499,25 +492,25 @@ class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PT12_H = "PT12H" PT1_D = "PT1D" -class TriggerEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Trigger Kind. - """ + +class TriggerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trigger Kind.""" FILE_EVENT = "FileEvent" PERIODIC_TIMER_EVENT = "PeriodicTimerEvent" -class UpdateOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current update operation. - """ + +class UpdateOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current update operation.""" NONE = "None" SCAN = "Scan" DOWNLOAD = "Download" INSTALL = "Install" -class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current stage of the update operation. - """ + +class UpdateOperationStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current stage of the update operation.""" UNKNOWN = "Unknown" INITIAL = "Initial" @@ -537,9 +530,9 @@ class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESCAN_COMPLETE = "RescanComplete" RESCAN_FAILED = "RescanFailed" -class UserType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of the user. - """ + +class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the user.""" SHARE = "Share" LOCAL_MANAGEMENT = "LocalManagement" diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_models.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_models.py deleted file mode 100644 index d4b0f61fd347..000000000000 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_models.py +++ /dev/null @@ -1,5037 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class ARMBaseModel(msrest.serialization.Model): - """Represents the base class for all object models. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Addon(ARMBaseModel): - """Role Addon. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ArcAddon, IoTAddon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - _subtype_map = { - 'kind': {'ArcForKubernetes': 'ArcAddon', 'IotEdge': 'IoTAddon'} - } - - def __init__( - self, - **kwargs - ): - super(Addon, self).__init__(**kwargs) - self.kind = 'Addon' # type: str - self.system_data = None - - -class AddonList(msrest.serialization.Model): - """Collection of all the Role addon on the Azure Stack Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Address(msrest.serialization.Model): - """The shipping address of the customer. - - All required parameters must be populated in order to send to Azure. - - :param address_line1: The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: The postal code. - :type postal_code: str - :param city: The city name. - :type city: str - :param state: The state name. - :type state: str - :param country: Required. The country name. - :type country: str - """ - - _validation = { - 'country': {'required': True}, - } - - _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Address, self).__init__(**kwargs) - self.address_line1 = kwargs.get('address_line1', None) - self.address_line2 = kwargs.get('address_line2', None) - self.address_line3 = kwargs.get('address_line3', None) - self.postal_code = kwargs.get('postal_code', None) - self.city = kwargs.get('city', None) - self.state = kwargs.get('state', None) - self.country = kwargs['country'] - - -class Alert(ARMBaseModel): - """Alert on the data box edge/gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Alert generated in the resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :ivar title: Alert title. - :vartype title: str - :ivar alert_type: Alert type. - :vartype alert_type: str - :ivar appeared_at_date_time: UTC time when the alert appeared. - :vartype appeared_at_date_time: ~datetime.datetime - :ivar recommendation: Alert recommendation. - :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", - "Critical". - :vartype severity: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AlertSeverity - :ivar error_details: Error details of the alert. - :vartype error_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AlertErrorDetails - :ivar detailed_information: Alert details. - :vartype detailed_information: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) - self.system_data = None - self.title = None - self.alert_type = None - self.appeared_at_date_time = None - self.recommendation = None - self.severity = None - self.error_details = None - self.detailed_information = None - - -class AlertErrorDetails(msrest.serialization.Model): - """Error details for the alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code. - :vartype error_code: str - :ivar error_message: Error Message. - :vartype error_message: str - :ivar occurrences: Number of occurrences. - :vartype occurrences: int - """ - - _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) - self.error_code = None - self.error_message = None - self.occurrences = None - - -class AlertList(msrest.serialization.Model): - """Collection of alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Alert] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ArcAddon(Addon): - """Arc Addon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param subscription_id: Required. Arc resource subscription Id. - :type subscription_id: str - :param resource_group_name: Required. Arc resource group name. - :type resource_group_name: str - :param resource_name: Required. Arc resource Name. - :type resource_name: str - :param resource_location: Required. Arc resource location. - :type resource_location: str - :ivar version: Arc resource version. - :vartype version: str - :ivar host_platform: Host OS supported by the Arc addon. Possible values include: "Windows", - "Linux". - :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'subscription_id': {'required': True}, - 'resource_group_name': {'required': True}, - 'resource_name': {'required': True}, - 'resource_location': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'properties.resourceGroupName', 'type': 'str'}, - 'resource_name': {'key': 'properties.resourceName', 'type': 'str'}, - 'resource_location': {'key': 'properties.resourceLocation', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArcAddon, self).__init__(**kwargs) - self.kind = 'ArcForKubernetes' # type: str - self.subscription_id = kwargs['subscription_id'] - self.resource_group_name = kwargs['resource_group_name'] - self.resource_name = kwargs['resource_name'] - self.resource_location = kwargs['resource_location'] - self.version = None - self.host_platform = None - self.host_platform_type = None - self.provisioning_state = None - - -class AsymmetricEncryptedSecret(msrest.serialization.Model): - """Represent the secrets intended for encryption with asymmetric key pair. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the - value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EncryptionAlgorithm - """ - - _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) - self.value = kwargs['value'] - self.encryption_cert_thumbprint = kwargs.get('encryption_cert_thumbprint', None) - self.encryption_algorithm = kwargs['encryption_algorithm'] - - -class Authentication(msrest.serialization.Model): - """Authentication mechanism for IoT devices. - - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SymmetricKey - """ - - _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, - } - - def __init__( - self, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) - self.symmetric_key = kwargs.get('symmetric_key', None) - - -class AzureContainerInfo(msrest.serialization.Model): - """Azure container mapping of the endpoint. - - All required parameters must be populated in order to send to Azure. - - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AzureContainerDataFormat - """ - - _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, - } - - _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) - self.storage_account_credential_id = kwargs['storage_account_credential_id'] - self.container_name = kwargs['container_name'] - self.data_format = kwargs['data_format'] - - -class BandwidthSchedule(ARMBaseModel): - """The bandwidth schedule details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Bandwidth object related to ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DayOfWeek] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) - self.system_data = None - self.start = kwargs['start'] - self.stop = kwargs['stop'] - self.rate_in_mbps = kwargs['rate_in_mbps'] - self.days = kwargs['days'] - - -class BandwidthSchedulesList(msrest.serialization.Model): - """The collection of bandwidth schedules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of bandwidth schedules. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ClientAccessRight(msrest.serialization.Model): - """The mapping between a particular client IP and the type of access client has on the NFS share. - - All required parameters must be populated in order to send to Azure. - - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ClientPermissionType - """ - - _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, - } - - _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) - self.client = kwargs['client'] - self.access_permission = kwargs['access_permission'] - - -class Role(ARMBaseModel): - """Compute role. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - _subtype_map = { - 'kind': {'CloudEdgeManagement': 'CloudEdgeManagementRole', 'IOT': 'IoTRole', 'Kubernetes': 'KubernetesRole', 'MEC': 'MECRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str - self.system_data = None - - -class CloudEdgeManagementRole(Role): - """CloudEdgeManagementRole role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :ivar local_management_status: Local Edge Management Status. Possible values include: - "Enabled", "Disabled". - :vartype local_management_status: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus - :ivar edge_profile: Edge Profile of the resource. - :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfile - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'local_management_status': {'readonly': True}, - 'edge_profile': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'local_management_status': {'key': 'properties.localManagementStatus', 'type': 'str'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudEdgeManagementRole, self).__init__(**kwargs) - self.kind = 'CloudEdgeManagement' # type: str - self.local_management_status = None - self.edge_profile = None - self.role_status = kwargs.get('role_status', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class CniConfig(msrest.serialization.Model): - """Cni configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Cni type. - :vartype type: str - :ivar version: Cni version. - :vartype version: str - :ivar pod_subnet: Pod Subnet. - :vartype pod_subnet: str - :ivar service_subnet: Service subnet. - :vartype service_subnet: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - 'pod_subnet': {'readonly': True}, - 'service_subnet': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'pod_subnet': {'key': 'podSubnet', 'type': 'str'}, - 'service_subnet': {'key': 'serviceSubnet', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CniConfig, self).__init__(**kwargs) - self.type = None - self.version = None - self.pod_subnet = None - self.service_subnet = None - - -class ComputeResource(msrest.serialization.Model): - """Compute infrastructure Resource. - - All required parameters must be populated in order to send to Azure. - - :param processor_count: Required. Processor count. - :type processor_count: int - :param memory_in_gb: Required. Memory in GB. - :type memory_in_gb: long - """ - - _validation = { - 'processor_count': {'required': True}, - 'memory_in_gb': {'required': True}, - } - - _attribute_map = { - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeResource, self).__init__(**kwargs) - self.processor_count = kwargs['processor_count'] - self.memory_in_gb = kwargs['memory_in_gb'] - - -class ContactDetails(msrest.serialization.Model): - """Contains all the contact details of the customer. - - All required parameters must be populated in order to send to Azure. - - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] - """ - - _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) - self.contact_person = kwargs['contact_person'] - self.company_name = kwargs['company_name'] - self.phone = kwargs['phone'] - self.email_list = kwargs['email_list'] - - -class Container(ARMBaseModel): - """Represents a container on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Container in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". - :vartype container_status: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AzureContainerDataFormat - :ivar refresh_details: Details of the refresh job on this container. - :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RefreshDetails - :ivar created_date_time: The UTC time when container got created. - :vartype created_date_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Container, self).__init__(**kwargs) - self.system_data = None - self.container_status = None - self.data_format = kwargs['data_format'] - self.refresh_details = None - self.created_date_time = None - - -class ContainerList(msrest.serialization.Model): - """Collection of all the containers on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of containers. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevice(ARMBaseModel): - """The Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure - geographical region (for example, West US, East US, or Southeast Asia). The geographical region - of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceIdentity - :ivar kind: The etag for the devices. Possible values include: "AzureDataBoxGateway", - "AzureStackEdge", "AzureStackHub", "AzureModularDataCentre". - :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceKind - :ivar system_data: DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceStatus - :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. - :vartype serial_number: str - :ivar description: The Description of the Data Box Edge/Gateway device. - :vartype description: str - :ivar model_description: The description of the Data Box Edge/Gateway device model. - :vartype model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". - :vartype device_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DeviceType - :ivar friendly_name: The Data Box Edge/Gateway device name. - :vartype friendly_name: str - :ivar culture: The Data Box Edge/Gateway device culture. - :vartype culture: str - :ivar device_model: The Data Box Edge/Gateway device model. - :vartype device_model: str - :ivar device_software_version: The Data Box Edge/Gateway device software version. - :vartype device_software_version: str - :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long - :ivar time_zone: The Data Box Edge/Gateway device timezone. - :vartype time_zone: str - :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). - :vartype device_hcs_version: str - :ivar configured_role_types: Type of compute roles configured. - :vartype configured_role_types: list[str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes] - :ivar node_count: The number of nodes in the cluster. - :vartype node_count: int - :ivar resource_move_details: The details of the move operation on this resource. - :vartype resource_move_details: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceMoveDetails - :ivar edge_profile: The details of Edge Profile for this resource. - :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfile - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'system_data': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'description': {'readonly': True}, - 'model_description': {'readonly': True}, - 'device_type': {'readonly': True}, - 'friendly_name': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'edge_profile': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - 'resource_move_details': {'key': 'properties.resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - self.etag = kwargs.get('etag', None) - self.identity = kwargs.get('identity', None) - self.kind = None - self.system_data = None - self.data_box_edge_device_status = kwargs.get('data_box_edge_device_status', None) - self.serial_number = None - self.description = None - self.model_description = None - self.device_type = None - self.friendly_name = None - self.culture = None - self.device_model = None - self.device_software_version = None - self.device_local_capacity = None - self.time_zone = None - self.device_hcs_version = None - self.configured_role_types = None - self.node_count = None - self.resource_move_details = None - self.edge_profile = None - - -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): - """The extended Info of the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to - encrypt any secret. - :type encryption_key: str - :ivar resource_key: The Resource ID of the Resource. - :vartype resource_key: str - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key - Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client - Key Vault. - :type channel_integrity_key_version: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - 'client_secret_store_id': {'key': 'properties.clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'properties.clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'properties.channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'properties.channelIntegrityKeyVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) - self.encryption_key_thumbprint = kwargs.get('encryption_key_thumbprint', None) - self.encryption_key = kwargs.get('encryption_key', None) - self.resource_key = None - self.client_secret_store_id = kwargs.get('client_secret_store_id', None) - self.client_secret_store_url = kwargs.get('client_secret_store_url', None) - self.channel_integrity_key_name = kwargs.get('channel_integrity_key_name', None) - self.channel_integrity_key_version = kwargs.get('channel_integrity_key_version', None) - - -class DataBoxEdgeDeviceExtendedInfoPatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device extended info patch. - - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key - Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client - Key Vault. - :type channel_integrity_key_version: str - """ - - _attribute_map = { - 'client_secret_store_id': {'key': 'clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'channelIntegrityKeyVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfoPatch, self).__init__(**kwargs) - self.client_secret_store_id = kwargs.get('client_secret_store_id', None) - self.client_secret_store_url = kwargs.get('client_secret_store_url', None) - self.channel_integrity_key_name = kwargs.get('channel_integrity_key_name', None) - self.channel_integrity_key_version = kwargs.get('channel_integrity_key_version', None) - - -class DataBoxEdgeDeviceList(msrest.serialization.Model): - """The collection of Data Box Edge/Gateway devices. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Data Box Edge/Gateway devices. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevicePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device patch. - - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceIdentity - :param edge_profile: Edge Profile property of the Data Box Edge/Gateway device. - :type edge_profile: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfilePatch - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfilePatch'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.identity = kwargs.get('identity', None) - self.edge_profile = kwargs.get('edge_profile', None) - - -class DataBoxEdgeMoveRequest(msrest.serialization.Model): - """Resource Move details. - - All required parameters must be populated in order to send to Azure. - - :param target_resource_group: Required. Target resource group ARMId. - :type target_resource_group: str - :param resources: Required. List of resources to be moved. - :type resources: list[str] - """ - - _validation = { - 'target_resource_group': {'required': True}, - 'resources': {'required': True}, - } - - _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeMoveRequest, self).__init__(**kwargs) - self.target_resource_group = kwargs['target_resource_group'] - self.resources = kwargs['resources'] - - -class DataBoxEdgeSku(msrest.serialization.Model): - """The Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". - :vartype name: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuName - :ivar kind: The Sku kind. - :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". - :vartype tier: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuTier - :ivar size: The Sku kind. - :vartype size: str - :ivar family: The Sku family. - :vartype family: str - :ivar locations: Availability of the Sku for the region. - :vartype locations: list[str] - :ivar api_versions: The API versions in which Sku is available. - :vartype api_versions: list[str] - :ivar location_info: Availability of the Sku for the location/zone/site. - :vartype location_info: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuLocationInfo] - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuCost] - :ivar signup_option: Sku can be signed up by customer or not. Possible values include: "None", - "Available". - :vartype signup_option: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuSignupOption - :ivar version: Availability of the Sku as preview/stable. Possible values include: "Stable", - "Preview". - :vartype version: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuVersion - :ivar availability: Links to the next set of results. Possible values include: "Available", - "Unavailable". - :vartype availability: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuAvailability - :ivar shipment_types: List of Shipment Types supported by this SKU. - :vartype shipment_types: list[str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShipmentType] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - 'shipment_types': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, - 'shipment_types': {'key': 'shipmentTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) - self.resource_type = None - self.name = None - self.kind = None - self.tier = None - self.size = None - self.family = None - self.locations = None - self.api_versions = None - self.location_info = None - self.costs = None - self.signup_option = None - self.version = None - self.availability = None - self.shipment_types = None - - -class DataBoxEdgeSkuList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceType Sku. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DCAccessCode(msrest.serialization.Model): - """DC Access code in the case of Self Managed Shipping. - - :param auth_code: DCAccess Code for the Self Managed shipment. - :type auth_code: str - """ - - _attribute_map = { - 'auth_code': {'key': 'properties.authCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DCAccessCode, self).__init__(**kwargs) - self.auth_code = kwargs.get('auth_code', None) - - -class EdgeProfile(msrest.serialization.Model): - """Details about Edge Profile for the resource. - - :param subscription: Edge Profile Subscription. - :type subscription: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfileSubscription - """ - - _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscription'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfile, self).__init__(**kwargs) - self.subscription = kwargs.get('subscription', None) - - -class EdgeProfilePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway Edge Profile patch. - - :param subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. - :type subscription: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfileSubscriptionPatch - """ - - _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscriptionPatch'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfilePatch, self).__init__(**kwargs) - self.subscription = kwargs.get('subscription', None) - - -class EdgeProfileSubscription(msrest.serialization.Model): - """Subscription details for the Edge Profile. - - :param registration_id: Edge Subscription Registration ID. - :type registration_id: str - :param id: ARM ID of the subscription. - :type id: str - :param state: Possible values include: "Registered", "Warned", "Suspended", "Deleted", - "Unregistered". - :type state: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SubscriptionState - :param registration_date: - :type registration_date: str - :param subscription_id: - :type subscription_id: str - :param tenant_id: - :type tenant_id: str - :param location_placement_id: - :type location_placement_id: str - :param quota_id: - :type quota_id: str - :param serialized_details: - :type serialized_details: str - :param registered_features: - :type registered_features: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SubscriptionRegisteredFeatures] - """ - - _attribute_map = { - 'registration_id': {'key': 'registrationId', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'registration_date': {'key': 'registrationDate', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'location_placement_id': {'key': 'properties.locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'properties.quotaId', 'type': 'str'}, - 'serialized_details': {'key': 'properties.serializedDetails', 'type': 'str'}, - 'registered_features': {'key': 'properties.registeredFeatures', 'type': '[SubscriptionRegisteredFeatures]'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfileSubscription, self).__init__(**kwargs) - self.registration_id = kwargs.get('registration_id', None) - self.id = kwargs.get('id', None) - self.state = kwargs.get('state', None) - self.registration_date = kwargs.get('registration_date', None) - self.subscription_id = kwargs.get('subscription_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.location_placement_id = kwargs.get('location_placement_id', None) - self.quota_id = kwargs.get('quota_id', None) - self.serialized_details = kwargs.get('serialized_details', None) - self.registered_features = kwargs.get('registered_features', None) - - -class EdgeProfileSubscriptionPatch(msrest.serialization.Model): - """The Data Box Edge/Gateway Edge Profile Subscription patch. - - :param id: The path ID that uniquely identifies the subscription of the edge profile. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfileSubscriptionPatch, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class EtcdInfo(msrest.serialization.Model): - """Etcd configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Etcd type. - :vartype type: str - :ivar version: Etcd version. - :vartype version: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EtcdInfo, self).__init__(**kwargs) - self.type = None - self.version = None - - -class Trigger(ARMBaseModel): - """Trigger details. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerEventType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } - - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.system_data = None - self.kind = 'Trigger' # type: str - - -class FileEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class FileSourceInfo(msrest.serialization.Model): - """File source details. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. File share ID. - :type share_id: str - """ - - _validation = { - 'share_id': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - - -class GenerateCertResponse(msrest.serialization.Model): - """Used in activation key generation flow. - - :param public_key: Gets or sets base64 encoded certificate raw data, - this is the public part needed to be uploaded to cert vault. - :type public_key: str - :param private_key: Gets or sets base64 encoded private part of the certificate, - needed to form the activation key. - :type private_key: str - :param expiry_time_in_utc: Gets or sets expiry time in UTC. - :type expiry_time_in_utc: str - """ - - _attribute_map = { - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'expiry_time_in_utc': {'key': 'expiryTimeInUTC', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GenerateCertResponse, self).__init__(**kwargs) - self.public_key = kwargs.get('public_key', None) - self.private_key = kwargs.get('private_key', None) - self.expiry_time_in_utc = kwargs.get('expiry_time_in_utc', None) - - -class ImageRepositoryCredential(msrest.serialization.Model): - """Image repository credential. - - All required parameters must be populated in order to send to Azure. - - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, - } - - _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageRepositoryCredential, self).__init__(**kwargs) - self.image_repository_url = kwargs['image_repository_url'] - self.user_name = kwargs['user_name'] - self.password = kwargs.get('password', None) - - -class IoTAddon(Addon): - """IoT Addon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param io_t_device_details: Required. IoT device metadata to which appliance needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: Required. IoT edge device to which the IoT Addon needs to be - configured. - :type io_t_edge_device_details: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo - :ivar version: Version of IoT running on the appliance. - :vartype version: str - :ivar host_platform: Host OS supported by the IoT addon. Possible values include: "Windows", - "Linux". - :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'io_t_device_details': {'required': True}, - 'io_t_edge_device_details': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTAddon, self).__init__(**kwargs) - self.kind = 'IotEdge' # type: str - self.io_t_device_details = kwargs['io_t_device_details'] - self.io_t_edge_device_details = kwargs['io_t_edge_device_details'] - self.version = None - self.host_platform = None - self.host_platform_type = None - self.provisioning_state = None - - -class IoTDeviceInfo(msrest.serialization.Model): - """Metadata of IoT device/IoT Edge device to be configured. - - All required parameters must be populated in order to send to Azure. - - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Authentication - """ - - _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) - self.device_id = kwargs['device_id'] - self.io_t_host_hub = kwargs['io_t_host_hub'] - self.io_t_host_hub_id = kwargs.get('io_t_host_hub_id', None) - self.authentication = kwargs.get('authentication', None) - - -class IoTEdgeAgentInfo(msrest.serialization.Model): - """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. - - All required parameters must be populated in order to send to Azure. - - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ImageRepositoryCredential - """ - - _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, - } - - _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) - self.image_name = kwargs['image_name'] - self.tag = kwargs['tag'] - self.image_repository = kwargs.get('image_repository', None) - - -class IoTRole(Role): - """Compute role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", - "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot - runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.HostPlatformType - :param compute_resource: Resource allocation. - :type compute_resource: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ComputeResource - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'compute_resource': {'key': 'properties.computeResource', 'type': 'ComputeResource'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.io_t_device_details = kwargs.get('io_t_device_details', None) - self.io_t_edge_device_details = kwargs.get('io_t_edge_device_details', None) - self.share_mappings = kwargs.get('share_mappings', None) - self.io_t_edge_agent_info = kwargs.get('io_t_edge_agent_info', None) - self.host_platform_type = None - self.compute_resource = kwargs.get('compute_resource', None) - self.role_status = kwargs.get('role_status', None) - - -class Ipv4Config(msrest.serialization.Model): - """Details related to the IPv4 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv4 address of the network adapter. - :vartype ip_address: str - :ivar subnet: The IPv4 subnet of the network adapter. - :vartype subnet: str - :ivar gateway: The IPv4 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) - self.ip_address = None - self.subnet = None - self.gateway = None - - -class Ipv6Config(msrest.serialization.Model): - """Details related to the IPv6 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv6 address of the network adapter. - :vartype ip_address: str - :ivar prefix_length: The IPv6 prefix of the network adapter. - :vartype prefix_length: int - :ivar gateway: The IPv6 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) - self.ip_address = None - self.prefix_length = None - self.gateway = None - - -class Job(msrest.serialization.Model): - """A device job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The name of the object. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.JobStatus - :ivar start_time: The UTC date and time at which the job started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The UTC date and time at which the job completed. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: The percentage of the job that is complete. - :vartype percent_complete: int - :ivar error: The error details. - :vartype error: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer", "Backup", "Restore", - "TriggerSupportPackage". - :vartype job_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", - "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", - "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". - :vartype current_stage: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UpdateOperationStage - :ivar download_progress: The download progress. - :vartype download_progress: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UpdateDownloadProgress - :ivar install_progress: The install progress. - :vartype install_progress: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UpdateInstallProgress - :ivar total_refresh_errors: Total number of errors encountered during the refresh process. - :vartype total_refresh_errors: int - :ivar error_manifest_file: Local share/remote container relative path to the error manifest - file of the refresh. - :vartype error_manifest_file: str - :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. - :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_time = None - self.end_time = None - self.percent_complete = None - self.error = None - self.job_type = None - self.current_stage = None - self.download_progress = None - self.install_progress = None - self.total_refresh_errors = None - self.error_manifest_file = None - self.refreshed_entity_id = None - self.folder = kwargs.get('folder', None) - - -class JobErrorDetails(msrest.serialization.Model): - """The job error information containing the list of job errors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_details: The error details. - :vartype error_details: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.JobErrorItem] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) - self.error_details = None - self.code = None - self.message = None - - -class JobErrorItem(msrest.serialization.Model): - """The job error items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendations: The recommended actions. - :vartype recommendations: list[str] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) - self.recommendations = None - self.code = None - self.message = None - - -class KubernetesClusterInfo(msrest.serialization.Model): - """Kubernetes cluster configuration. - - 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 etcd_info: Etcd configuration. - :vartype etcd_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EtcdInfo - :ivar nodes: Kubernetes cluster nodes. - :vartype nodes: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.NodeInfo] - :param version: Required. Kubernetes cluster version. - :type version: str - """ - - _validation = { - 'etcd_info': {'readonly': True}, - 'nodes': {'readonly': True}, - 'version': {'required': True}, - } - - _attribute_map = { - 'etcd_info': {'key': 'etcdInfo', 'type': 'EtcdInfo'}, - 'nodes': {'key': 'nodes', 'type': '[NodeInfo]'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesClusterInfo, self).__init__(**kwargs) - self.etcd_info = None - self.nodes = None - self.version = kwargs['version'] - - -class KubernetesIPConfiguration(msrest.serialization.Model): - """Kubernetes node IP configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar port: Port of the Kubernetes node. - :vartype port: str - :param ip_address: IP address of the Kubernetes node. - :type ip_address: str - """ - - _validation = { - 'port': {'readonly': True}, - } - - _attribute_map = { - 'port': {'key': 'port', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesIPConfiguration, self).__init__(**kwargs) - self.port = None - self.ip_address = kwargs.get('ip_address', None) - - -class KubernetesRole(Role): - """Kubernetes role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param host_platform: Host OS supported by the Kubernetes role. Possible values include: - "Windows", "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType - :ivar provisioning_state: State of Kubernetes deployment. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesState - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.HostPlatformType - :param kubernetes_cluster_info: Kubernetes cluster configuration. - :type kubernetes_cluster_info: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesClusterInfo - :param kubernetes_role_resources: Kubernetes role resources. - :type kubernetes_role_resources: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleResources - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'kubernetes_cluster_info': {'key': 'properties.kubernetesClusterInfo', 'type': 'KubernetesClusterInfo'}, - 'kubernetes_role_resources': {'key': 'properties.kubernetesRoleResources', 'type': 'KubernetesRoleResources'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRole, self).__init__(**kwargs) - self.kind = 'Kubernetes' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.provisioning_state = None - self.host_platform_type = None - self.kubernetes_cluster_info = kwargs.get('kubernetes_cluster_info', None) - self.kubernetes_role_resources = kwargs.get('kubernetes_role_resources', None) - self.role_status = kwargs.get('role_status', None) - - -class KubernetesRoleCompute(msrest.serialization.Model): - """Kubernetes role compute resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param vm_profile: Required. VM profile. - :type vm_profile: str - :ivar memory_in_bytes: Memory in bytes. - :vartype memory_in_bytes: long - :ivar processor_count: Processor count. - :vartype processor_count: int - """ - - _validation = { - 'vm_profile': {'required': True}, - 'memory_in_bytes': {'readonly': True}, - 'processor_count': {'readonly': True}, - } - - _attribute_map = { - 'vm_profile': {'key': 'vmProfile', 'type': 'str'}, - 'memory_in_bytes': {'key': 'memoryInBytes', 'type': 'long'}, - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleCompute, self).__init__(**kwargs) - self.vm_profile = kwargs['vm_profile'] - self.memory_in_bytes = None - self.processor_count = None - - -class KubernetesRoleNetwork(msrest.serialization.Model): - """Kubernetes role network resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar cni_config: Cni configuration. - :vartype cni_config: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.CniConfig - :ivar load_balancer_config: Load balancer configuration. - :vartype load_balancer_config: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.LoadBalancerConfig - """ - - _validation = { - 'cni_config': {'readonly': True}, - 'load_balancer_config': {'readonly': True}, - } - - _attribute_map = { - 'cni_config': {'key': 'cniConfig', 'type': 'CniConfig'}, - 'load_balancer_config': {'key': 'loadBalancerConfig', 'type': 'LoadBalancerConfig'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleNetwork, self).__init__(**kwargs) - self.cni_config = None - self.load_balancer_config = None - - -class KubernetesRoleResources(msrest.serialization.Model): - """Kubernetes role resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param storage: Kubernetes role storage resource. - :type storage: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleStorage - :param compute: Required. Kubernetes role compute resource. - :type compute: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleCompute - :ivar network: Kubernetes role network resource. - :vartype network: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleNetwork - """ - - _validation = { - 'compute': {'required': True}, - 'network': {'readonly': True}, - } - - _attribute_map = { - 'storage': {'key': 'storage', 'type': 'KubernetesRoleStorage'}, - 'compute': {'key': 'compute', 'type': 'KubernetesRoleCompute'}, - 'network': {'key': 'network', 'type': 'KubernetesRoleNetwork'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleResources, self).__init__(**kwargs) - self.storage = kwargs.get('storage', None) - self.compute = kwargs['compute'] - self.network = None - - -class KubernetesRoleStorage(msrest.serialization.Model): - """Kubernetes role storage resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar storage_classes: Kubernetes storage class info. - :vartype storage_classes: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleStorageClassInfo] - :param endpoints: Mount points of shares in role(s). - :type endpoints: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] - """ - - _validation = { - 'storage_classes': {'readonly': True}, - } - - _attribute_map = { - 'storage_classes': {'key': 'storageClasses', 'type': '[KubernetesRoleStorageClassInfo]'}, - 'endpoints': {'key': 'endpoints', 'type': '[MountPointMap]'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorage, self).__init__(**kwargs) - self.storage_classes = None - self.endpoints = kwargs.get('endpoints', None) - - -class KubernetesRoleStorageClassInfo(msrest.serialization.Model): - """Kubernetes storage class info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Storage class name. - :vartype name: str - :ivar type: Storage class type. - :vartype type: str - :ivar posix_compliant: If provisioned storage is posix compliant. Possible values include: - "Invalid", "Enabled", "Disabled". - :vartype posix_compliant: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PosixComplianceStatus - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'posix_compliant': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'posix_compliant': {'key': 'posixCompliant', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorageClassInfo, self).__init__(**kwargs) - self.name = None - self.type = None - self.posix_compliant = None - - -class LoadBalancerConfig(msrest.serialization.Model): - """Load balancer configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Load balancer type. - :vartype type: str - :ivar version: Load balancer version. - :vartype version: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LoadBalancerConfig, self).__init__(**kwargs) - self.type = None - self.version = None - - -class MECRole(Role): - """MEC role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param connection_string: Activation key of the MEC. - :type connection_string: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'AsymmetricEncryptedSecret'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MECRole, self).__init__(**kwargs) - self.kind = 'MEC' # type: str - self.connection_string = kwargs.get('connection_string', None) - self.role_status = kwargs.get('role_status', None) - - -class MetricConfiguration(msrest.serialization.Model): - """Metric configuration. - - All required parameters must be populated in order to send to Azure. - - :param resource_id: Required. The Resource ID on which the metrics should be pushed. - :type resource_id: str - :param mdm_account: The MDM account to which the counters should be pushed. - :type mdm_account: str - :param metric_name_space: The MDM namespace to which the counters should be pushed. This is - required if MDMAccount is specified. - :type metric_name_space: str - :param counter_sets: Required. Host name for the IoT hub associated to the device. - :type counter_sets: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCounterSet] - """ - - _validation = { - 'resource_id': {'required': True}, - 'counter_sets': {'required': True}, - } - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'mdm_account': {'key': 'mdmAccount', 'type': 'str'}, - 'metric_name_space': {'key': 'metricNameSpace', 'type': 'str'}, - 'counter_sets': {'key': 'counterSets', 'type': '[MetricCounterSet]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricConfiguration, self).__init__(**kwargs) - self.resource_id = kwargs['resource_id'] - self.mdm_account = kwargs.get('mdm_account', None) - self.metric_name_space = kwargs.get('metric_name_space', None) - self.counter_sets = kwargs['counter_sets'] - - -class MetricCounter(msrest.serialization.Model): - """The metric counter. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The counter name. - :type name: str - :param instance: The instance from which counter should be collected. - :type instance: str - :param dimension_filter: The dimension filter. - :type dimension_filter: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimension] - :param additional_dimensions: The additional dimensions to be added to metric. - :type additional_dimensions: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimension] - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, - 'dimension_filter': {'key': 'dimensionFilter', 'type': '[MetricDimension]'}, - 'additional_dimensions': {'key': 'additionalDimensions', 'type': '[MetricDimension]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCounter, self).__init__(**kwargs) - self.name = kwargs['name'] - self.instance = kwargs.get('instance', None) - self.dimension_filter = kwargs.get('dimension_filter', None) - self.additional_dimensions = kwargs.get('additional_dimensions', None) - - -class MetricCounterSet(msrest.serialization.Model): - """The metric counter set. - - All required parameters must be populated in order to send to Azure. - - :param counters: Required. The counters that should be collected in this set. - :type counters: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCounter] - """ - - _validation = { - 'counters': {'required': True}, - } - - _attribute_map = { - 'counters': {'key': 'counters', 'type': '[MetricCounter]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCounterSet, self).__init__(**kwargs) - self.counters = kwargs['counters'] - - -class MetricDimension(msrest.serialization.Model): - """The metric dimension. - - All required parameters must be populated in order to send to Azure. - - :param source_type: Required. The dimension type. - :type source_type: str - :param source_name: Required. The dimension value. - :type source_name: str - """ - - _validation = { - 'source_type': {'required': True}, - 'source_name': {'required': True}, - } - - _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'source_name': {'key': 'sourceName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) - self.source_type = kwargs['source_type'] - self.source_name = kwargs['source_name'] - - -class MetricDimensionV1(msrest.serialization.Model): - """Metric Dimension v1. - - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimensionV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecificationV1(msrest.serialization.Model): - """Metric specification version 1. - - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricAggregationType] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.dimensions = kwargs.get('dimensions', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - - -class MonitoringMetricConfiguration(ARMBaseModel): - """The metric setting details for the role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param metric_configurations: Required. The metrics configuration details. - :type metric_configurations: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricConfiguration] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'metric_configurations': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metric_configurations': {'key': 'properties.metricConfigurations', 'type': '[MetricConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfiguration, self).__init__(**kwargs) - self.metric_configurations = kwargs['metric_configurations'] - - -class MonitoringMetricConfigurationList(msrest.serialization.Model): - """Collection of metric configurations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of metric configurations. - :vartype value: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MonitoringMetricConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfigurationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class MountPointMap(msrest.serialization.Model): - """The share mount point. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str - :ivar role_id: ID of the role to which share is mounted. - :vartype role_id: str - :ivar mount_point: Mount point for the share. - :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". - :vartype mount_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive", - "MEC", "CloudEdgeManagement", "Kubernetes". - :vartype role_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes - """ - - _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.role_id = None - self.mount_point = None - self.mount_type = None - self.role_type = None - - -class NetworkAdapter(msrest.serialization.Model): - """Represents the networkAdapter on a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar adapter_id: Instance ID of network adapter. - :vartype adapter_id: str - :ivar adapter_position: Hardware position of network adapter. - :vartype adapter_position: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapterPosition - :ivar index: Logical index of the adapter. - :vartype index: int - :ivar node_id: Node ID of the network adapter. - :vartype node_id: str - :ivar network_adapter_name: Network adapter name. - :vartype network_adapter_name: str - :ivar label: Hardware label for the adapter. - :vartype label: str - :ivar mac_address: MAC address. - :vartype mac_address: str - :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". - :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapterDHCPStatus - :ivar ipv4_configuration: The IPv4 configuration of the network adapter. - :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Ipv4Config - :ivar ipv6_configuration: The IPv6 configuration of the network adapter. - :vartype ipv6_configuration: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Ipv6Config - :ivar ipv6_link_local_address: The IPv6 local address. - :vartype ipv6_link_local_address: str - :ivar dns_servers: The list of DNS Servers of the device. - :vartype dns_servers: list[str] - """ - - _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) - self.adapter_id = None - self.adapter_position = None - self.index = None - self.node_id = None - self.network_adapter_name = None - self.label = None - self.mac_address = None - self.link_speed = None - self.status = None - self.rdma_status = kwargs.get('rdma_status', None) - self.dhcp_status = kwargs.get('dhcp_status', None) - self.ipv4_configuration = None - self.ipv6_configuration = None - self.ipv6_link_local_address = None - self.dns_servers = None - - -class NetworkAdapterPosition(msrest.serialization.Model): - """The network adapter position. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". - :vartype network_group: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkGroup - :ivar port: The port. - :vartype port: int - """ - - _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, - } - - _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) - self.network_group = None - self.port = None - - -class NetworkSettings(ARMBaseModel): - """The network settings of a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar network_adapters: The network adapter list on the device. - :vartype network_adapters: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapter] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) - self.network_adapters = None - - -class Node(ARMBaseModel): - """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) - self.node_status = None - self.node_chassis_serial_number = None - self.node_serial_number = None - self.node_display_name = None - self.node_friendly_software_version = None - self.node_hcs_version = None - self.node_instance_id = None - - -class NodeInfo(msrest.serialization.Model): - """Kubernetes node info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Node name. - :vartype name: str - :ivar type: Node type - Master/Worker. Possible values include: "Invalid", "Master", "Worker". - :vartype type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesNodeType - :param ip_configuration: IP Configuration of the Kubernetes node. - :type ip_configuration: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesIPConfiguration] - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_configuration': {'key': 'ipConfiguration', 'type': '[KubernetesIPConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeInfo, self).__init__(**kwargs) - self.name = None - self.type = None - self.ip_configuration = kwargs.get('ip_configuration', None) - - -class NodeList(msrest.serialization.Model): - """Collection of Nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Nodes. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Node] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class Operation(msrest.serialization.Model): - """Operations. - - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param service_specification: Service specification. - :type service_specification: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ServiceSpecification - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationDisplay(msrest.serialization.Model): - """Operation display properties. - - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str - """ - - _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 = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """The list of operations used for the discovery of available provider operations. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class Order(ARMBaseModel): - """The order details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Address - :ivar current_status: Current status of the order. - :vartype current_status: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OrderStatus - :ivar order_history: List of status changes in the order. - :vartype order_history: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.OrderStatus] - :ivar serial_number: Serial number of the device. - :vartype serial_number: str - :ivar delivery_tracking_info: Tracking information for the package delivered to the customer - whether it has an original or a replacement device. - :vartype delivery_tracking_info: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.TrackingInfo] - :ivar return_tracking_info: Tracking information for the package returned from the customer - whether it has an original or a replacement device. - :vartype return_tracking_info: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.TrackingInfo] - :param shipment_type: ShipmentType of the order. Possible values include: "NotApplicable", - "ShippedToCustomer", "SelfPickup". - :type shipment_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShipmentType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'current_status': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - 'shipment_type': {'key': 'properties.shipmentType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Order, self).__init__(**kwargs) - self.contact_information = kwargs.get('contact_information', None) - self.shipping_address = kwargs.get('shipping_address', None) - self.current_status = None - self.order_history = None - self.serial_number = None - self.delivery_tracking_info = None - self.return_tracking_info = None - self.shipment_type = kwargs.get('shipment_type', None) - - -class OrderList(msrest.serialization.Model): - """List of order entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of orders. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OrderStatus(msrest.serialization.Model): - """Represents a single status change. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", - "AwaitingPickup", "PickupCompleted", "AwaitingDrop". - :type status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OrderState - :ivar update_date_time: Time of status update. - :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str - :ivar tracking_information: Tracking information related to the state in the ordering flow. - :vartype tracking_information: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TrackingInfo - :ivar additional_order_details: Dictionary to hold generic information which is not stored - by the already existing properties. - :vartype additional_order_details: dict[str, str] - """ - - _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'tracking_information': {'readonly': True}, - 'additional_order_details': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'tracking_information': {'key': 'trackingInformation', 'type': 'TrackingInfo'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) - self.status = kwargs['status'] - self.update_date_time = None - self.comments = kwargs.get('comments', None) - self.tracking_information = None - self.additional_order_details = None - - -class PeriodicTimerEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class PeriodicTimerSourceInfo(msrest.serialization.Model): - """Periodic timer event source. - - All required parameters must be populated in order to send to Azure. - - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str - """ - - _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) - self.start_time = kwargs['start_time'] - self.schedule = kwargs['schedule'] - self.topic = kwargs.get('topic', None) - - -class RefreshDetails(msrest.serialization.Model): - """Fields for tracking refresh job on the share or container. - - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or - container, this field indicates the ARM resource ID of that job. The field is empty if no job - is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh - job on this particular share or container, if any. This could be a failed job or a successful - job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or - container,if any. This could be a failed job or a successful job. - :type last_job: str - """ - - _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RefreshDetails, self).__init__(**kwargs) - self.in_progress_refresh_job_id = kwargs.get('in_progress_refresh_job_id', None) - self.last_completed_refresh_job_time_in_utc = kwargs.get('last_completed_refresh_job_time_in_utc', None) - self.error_manifest_file = kwargs.get('error_manifest_file', None) - self.last_job = kwargs.get('last_job', None) - - -class ResourceIdentity(msrest.serialization.Model): - """Msi identity details of the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param type: Identity type. Possible values include: "None", "SystemAssigned", "UserAssigned". - :type type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MsiIdentityType - :ivar principal_id: Service Principal Id backing the Msi. - :vartype principal_id: str - :ivar tenant_id: Home Tenant Id. - :vartype tenant_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.principal_id = None - self.tenant_id = None - - -class ResourceMoveDetails(msrest.serialization.Model): - """Fields for tracking resource move. - - :param operation_in_progress: Denotes whether move operation is in progress. Possible values - include: "None", "ResourceMoveInProgress", "ResourceMoveFailed". - :type operation_in_progress: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceMoveStatus - :param operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to - finish. - :type operation_in_progress_lock_timeout_in_utc: ~datetime.datetime - """ - - _attribute_map = { - 'operation_in_progress': {'key': 'operationInProgress', 'type': 'str'}, - 'operation_in_progress_lock_timeout_in_utc': {'key': 'operationInProgressLockTimeoutInUTC', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceMoveDetails, self).__init__(**kwargs) - self.operation_in_progress = kwargs.get('operation_in_progress', None) - self.operation_in_progress_lock_timeout_in_utc = kwargs.get('operation_in_progress_lock_timeout_in_utc', None) - - -class ResourceTypeSku(msrest.serialization.Model): - """Resource type Sku object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The resource type. - :vartype resource_type: str - :ivar skus: The skus. - :vartype skus: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuInformation] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'skus': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'skus': {'key': 'skus', 'type': '[SkuInformation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) - self.resource_type = None - self.skus = None - - -class RoleList(msrest.serialization.Model): - """Collection of all the roles on the Data Box Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RoleSinkInfo(msrest.serialization.Model): - """Compute role against which events will be raised. - - All required parameters must be populated in order to send to Azure. - - :param role_id: Required. Compute role ID. - :type role_id: str - """ - - _validation = { - 'role_id': {'required': True}, - } - - _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) - self.role_id = kwargs['role_id'] - - -class SecuritySettings(ARMBaseModel): - """The security settings of a device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) - self.device_admin_password = kwargs['device_admin_password'] - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification. - - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricSpecificationV1] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Share(ARMBaseModel): - """Represents a share on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Share on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share - (required for SMB protocol). - :type user_access_rights: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the - share(required for NFS protocol). - :type client_access_rights: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RefreshDetails - :ivar share_mappings: Share mount point to the role. - :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Share, self).__init__(**kwargs) - self.system_data = None - self.description = kwargs.get('description', None) - self.share_status = kwargs['share_status'] - self.monitoring_status = kwargs['monitoring_status'] - self.azure_container_info = kwargs.get('azure_container_info', None) - self.access_protocol = kwargs['access_protocol'] - self.user_access_rights = kwargs.get('user_access_rights', None) - self.client_access_rights = kwargs.get('client_access_rights', None) - self.refresh_details = kwargs.get('refresh_details', None) - self.share_mappings = None - self.data_policy = kwargs.get('data_policy', None) - - -class ShareAccessRight(msrest.serialization.Model): - """Specifies the mapping between this particular user and the type of access he has on shares on this device. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessType - """ - - _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.access_type = kwargs['access_type'] - - -class ShareList(msrest.serialization.Model): - """Collection of all the shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of shares. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Sku(msrest.serialization.Model): - """The SKU type. - - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". - :type name: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuTier - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - - -class SkuCost(msrest.serialization.Model): - """The metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The cost quantity. - :vartype quantity: long - :ivar extended_unit: The extended unit. - :vartype extended_unit: str - """ - - _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, - } - - _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) - self.meter_id = None - self.quantity = None - self.extended_unit = None - - -class SkuInformation(msrest.serialization.Model): - """Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: The sku tier. - :vartype tier: str - :ivar kind: The sku kind. - :vartype kind: str - :ivar family: The Sku family. - :vartype family: str - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuCost] - :ivar locations: The locations where Sku is available. - :vartype locations: list[str] - :ivar location_info: The locations where Sku is available with zones and sites info. - :vartype location_info: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuLocationInfo] - :ivar required_quota_ids: The required quotaIds for the sku to be available. - :vartype required_quota_ids: list[str] - :ivar required_features: The required features for the sku to be available. - :vartype required_features: list[str] - """ - - _validation = { - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'family': {'readonly': True}, - 'costs': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) - self.name = None - self.tier = None - self.kind = None - self.family = None - self.costs = None - self.locations = None - self.location_info = None - self.required_quota_ids = None - self.required_features = None - - -class SkuInformationList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceTypeSku objects. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceTypeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SkuLocationInfo(msrest.serialization.Model): - """The location info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The location. - :vartype location: str - :ivar zones: The zones. - :vartype zones: list[str] - :ivar sites: The sites. - :vartype sites: list[str] - """ - - _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) - self.location = None - self.zones = None - self.sites = None - - -class StorageAccount(ARMBaseModel): - """Represents a Storage Account on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: StorageAccount object on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountStatus - :param data_policy: Required. Data policy of the storage Account. Possible values include: - "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str - :ivar blob_endpoint: BlobEndpoint of Storage Account. - :vartype blob_endpoint: str - :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy - set to Cloud. - :vartype container_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'data_policy': {'required': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccount, self).__init__(**kwargs) - self.system_data = None - self.description = kwargs.get('description', None) - self.storage_account_status = kwargs.get('storage_account_status', None) - self.data_policy = kwargs['data_policy'] - self.storage_account_credential_id = kwargs.get('storage_account_credential_id', None) - self.blob_endpoint = None - self.container_count = None - - -class StorageAccountCredential(ARMBaseModel): - """The storage account credential. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: StorageAccountCredential object. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredential, self).__init__(**kwargs) - self.system_data = None - self.alias = kwargs['alias'] - self.user_name = kwargs.get('user_name', None) - self.account_key = kwargs.get('account_key', None) - self.connection_string = kwargs.get('connection_string', None) - self.ssl_status = kwargs['ssl_status'] - self.blob_domain_name = kwargs.get('blob_domain_name', None) - self.account_type = kwargs['account_type'] - self.storage_account_id = kwargs.get('storage_account_id', None) - - -class StorageAccountCredentialList(msrest.serialization.Model): - """The collection of storage account credentials. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class StorageAccountList(msrest.serialization.Model): - """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of storageAccounts. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SubscriptionRegisteredFeatures(msrest.serialization.Model): - """SubscriptionRegisteredFeatures. - - :param name: - :type name: str - :param state: - :type state: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionRegisteredFeatures, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.state = kwargs.get('state', None) - - -class SymmetricKey(msrest.serialization.Model): - """Symmetric key for authentication. - - :param connection_string: Connection string based on the symmetric key. - :type connection_string: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret - """ - - _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) - self.connection_string = kwargs.get('connection_string', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type 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, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TrackingInfo(msrest.serialization.Model): - """Tracking courier information. - - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str - """ - - _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackingInfo, self).__init__(**kwargs) - self.serial_number = kwargs.get('serial_number', None) - self.carrier_name = kwargs.get('carrier_name', None) - self.tracking_id = kwargs.get('tracking_id', None) - self.tracking_url = kwargs.get('tracking_url', None) - - -class TriggerList(msrest.serialization.Model): - """Collection of all trigger on the data box edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of triggers. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UpdateDownloadProgress(msrest.serialization.Model): - """Details about the download progress of update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". - :vartype download_phase: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DownloadPhase - :ivar percent_complete: Percentage of completion. - :vartype percent_complete: int - :ivar total_bytes_to_download: Total bytes to download. - :vartype total_bytes_to_download: float - :ivar total_bytes_downloaded: Total bytes downloaded. - :vartype total_bytes_downloaded: float - :ivar number_of_updates_to_download: Number of updates to download. - :vartype number_of_updates_to_download: int - :ivar number_of_updates_downloaded: Number of updates downloaded. - :vartype number_of_updates_downloaded: int - """ - - _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, - } - - _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) - self.download_phase = None - self.percent_complete = None - self.total_bytes_to_download = None - self.total_bytes_downloaded = None - self.number_of_updates_to_download = None - self.number_of_updates_downloaded = None - - -class UpdateInstallProgress(msrest.serialization.Model): - """Progress details during installation of updates. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar percent_complete: Percentage completed. - :vartype percent_complete: int - :ivar number_of_updates_to_install: Number of updates to install. - :vartype number_of_updates_to_install: int - :ivar number_of_updates_installed: Number of updates installed. - :vartype number_of_updates_installed: int - """ - - _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, - } - - _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) - self.percent_complete = None - self.number_of_updates_to_install = None - self.number_of_updates_installed = None - - -class UpdateSummary(ARMBaseModel): - """Details about ongoing updates and availability of updates on the device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed - (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime - :ivar last_completed_download_job_date_time: The time when the last Download job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_download_job_date_time: ~datetime.datetime - :ivar last_completed_install_job_date_time: The time when the last Install job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_install_job_date_time: ~datetime.datetime - :ivar total_number_of_updates_available: The number of updates available for the current device - version as per the last device scan. - :vartype total_number_of_updates_available: int - :ivar total_number_of_updates_pending_download: The total number of items pending download. - :vartype total_number_of_updates_pending_download: int - :ivar total_number_of_updates_pending_install: The total number of items pending install. - :vartype total_number_of_updates_pending_install: int - :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". - :vartype ongoing_update_operation: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UpdateOperation - :ivar in_progress_download_job_id: The job ID of the download job in progress. - :vartype in_progress_download_job_id: str - :ivar in_progress_install_job_id: The job ID of the install job in progress. - :vartype in_progress_install_job_id: str - :ivar in_progress_download_job_started_date_time: The time when the currently running download - (if any) started. - :vartype in_progress_download_job_started_date_time: ~datetime.datetime - :ivar in_progress_install_job_started_date_time: The time when the currently running install - (if any) started. - :vartype in_progress_install_job_started_date_time: ~datetime.datetime - :ivar update_titles: The list of updates available for install. - :vartype update_titles: list[str] - :ivar total_update_size_in_bytes: The total size of updates available for download in bytes. - :vartype total_update_size_in_bytes: float - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateSummary, self).__init__(**kwargs) - self.device_version_number = kwargs.get('device_version_number', None) - self.friendly_device_version_name = kwargs.get('friendly_device_version_name', None) - self.device_last_scanned_date_time = kwargs.get('device_last_scanned_date_time', None) - self.last_completed_scan_job_date_time = kwargs.get('last_completed_scan_job_date_time', None) - self.last_completed_download_job_date_time = None - self.last_completed_install_job_date_time = None - self.total_number_of_updates_available = None - self.total_number_of_updates_pending_download = None - self.total_number_of_updates_pending_install = None - self.reboot_behavior = None - self.ongoing_update_operation = None - self.in_progress_download_job_id = None - self.in_progress_install_job_id = None - self.in_progress_download_job_started_date_time = None - self.in_progress_install_job_started_date_time = None - self.update_titles = None - self.total_update_size_in_bytes = None - - -class UploadCertificateRequest(msrest.serialization.Model): - """The upload certificate request. - - All required parameters must be populated in order to send to Azure. - - :param authentication_type: The authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type authentication_type: str or - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str - """ - - _validation = { - 'certificate': {'required': True}, - } - - _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) - self.authentication_type = kwargs.get('authentication_type', None) - self.certificate = kwargs['certificate'] - - -class UploadCertificateResponse(msrest.serialization.Model): - """The upload registration certificate response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param auth_type: Specifies authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AuthenticationType - :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. - :vartype resource_id: str - :ivar aad_authority: Azure Active Directory tenant authority. - :vartype aad_authority: str - :ivar aad_tenant_id: Azure Active Directory tenant ID. - :vartype aad_tenant_id: str - :ivar service_principal_client_id: Azure Active Directory service principal client ID. - :vartype service_principal_client_id: str - :ivar service_principal_object_id: Azure Active Directory service principal object ID. - :vartype service_principal_object_id: str - :ivar azure_management_endpoint_audience: The azure management endpoint audience. - :vartype azure_management_endpoint_audience: str - :ivar aad_audience: Identifier of the target resource that is the recipient of the requested - token. - :vartype aad_audience: str - """ - - _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, - } - - _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) - self.auth_type = kwargs.get('auth_type', None) - self.resource_id = None - self.aad_authority = None - self.aad_tenant_id = None - self.service_principal_client_id = None - self.service_principal_object_id = None - self.azure_management_endpoint_audience = None - self.aad_audience = None - - -class User(ARMBaseModel): - """Represents a user who has access to one or more shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: User in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param encrypted_password: The password details. - :type encrypted_password: - ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret - :ivar share_access_rights: List of shares that the user has rights on. This field should not be - specified during user creation. - :vartype share_access_rights: - list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessRight] - :param user_type: Type of the user. Possible values include: "Share", "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UserType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_access_rights': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.system_data = None - self.encrypted_password = kwargs.get('encrypted_password', None) - self.share_access_rights = None - self.user_type = kwargs.get('user_type', None) - - -class UserAccessRight(msrest.serialization.Model): - """The mapping between a particular user and the access type on the SMB share. - - All required parameters must be populated in order to send to Azure. - - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessType - """ - - _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) - self.user_id = kwargs['user_id'] - self.access_type = kwargs['access_type'] - - -class UserList(msrest.serialization.Model): - """Collection of users. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of users. - :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) - self.value = None - self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_models_py3.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_models_py3.py index 3ee92825fd2d..69cf6886bad0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_models_py3.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._data_box_edge_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ARMBaseModel(msrest.serialization.Model): +class ARMBaseModel(_serialization.Model): """Represents the base class for all object models. Variables are only populated by the server, and will be ignored when sending a request. @@ -28,22 +31,20 @@ class ARMBaseModel(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -52,8 +53,8 @@ def __init__( class Addon(ARMBaseModel): """Role Addon. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ArcAddon, IoTAddon. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ArcAddon, IoTAddon Variables are only populated by the server, and will be ignored when sending a request. @@ -65,43 +66,38 @@ class Addon(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - _subtype_map = { - 'kind': {'ArcForKubernetes': 'ArcAddon', 'IotEdge': 'IoTAddon'} - } + _subtype_map = {"kind": {"ArcForKubernetes": "ArcAddon", "IotEdge": "IoTAddon"}} - def __init__( - self, - **kwargs - ): - super(Addon, self).__init__(**kwargs) - self.kind = 'Addon' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None self.system_data = None -class AddonList(msrest.serialization.Model): +class AddonList(_serialization.Model): """Collection of all the Role addon on the Azure Stack Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -113,57 +109,55 @@ class AddonList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Addon]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Address(msrest.serialization.Model): +class Address(_serialization.Model): """The shipping address of the customer. All required parameters must be populated in order to send to Azure. - :param address_line1: The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: The postal code. - :type postal_code: str - :param city: The city name. - :type city: str - :param state: The state name. - :type state: str - :param country: Required. The country name. - :type country: str + :ivar address_line1: The address line1. + :vartype address_line1: str + :ivar address_line2: The address line2. + :vartype address_line2: str + :ivar address_line3: The address line3. + :vartype address_line3: str + :ivar postal_code: The postal code. + :vartype postal_code: str + :ivar city: The city name. + :vartype city: str + :ivar state: The state name. + :vartype state: str + :ivar country: The country name. Required. + :vartype country: str """ _validation = { - 'country': {'required': True}, + "country": {"required": True}, } _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, + "address_line1": {"key": "addressLine1", "type": "str"}, + "address_line2": {"key": "addressLine2", "type": "str"}, + "address_line3": {"key": "addressLine3", "type": "str"}, + "postal_code": {"key": "postalCode", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "country": {"key": "country", "type": "str"}, } def __init__( @@ -178,7 +172,23 @@ def __init__( state: Optional[str] = None, **kwargs ): - super(Address, self).__init__(**kwargs) + """ + :keyword address_line1: The address line1. + :paramtype address_line1: str + :keyword address_line2: The address line2. + :paramtype address_line2: str + :keyword address_line3: The address line3. + :paramtype address_line3: str + :keyword postal_code: The postal code. + :paramtype postal_code: str + :keyword city: The city name. + :paramtype city: str + :keyword state: The state name. + :paramtype state: str + :keyword country: The country name. Required. + :paramtype country: str + """ + super().__init__(**kwargs) self.address_line1 = address_line1 self.address_line2 = address_line2 self.address_line3 = address_line3 @@ -188,7 +198,7 @@ def __init__( self.country = country -class Alert(ARMBaseModel): +class Alert(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Alert on the data box edge/gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -209,7 +219,7 @@ class Alert(ARMBaseModel): :vartype appeared_at_date_time: ~datetime.datetime :ivar recommendation: Alert recommendation. :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", + :ivar severity: Severity of the alert. Known values are: "Informational", "Warning", and "Critical". :vartype severity: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AlertSeverity :ivar error_details: Error details of the alert. @@ -219,38 +229,36 @@ class Alert(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "title": {"readonly": True}, + "alert_type": {"readonly": True}, + "appeared_at_date_time": {"readonly": True}, + "recommendation": {"readonly": True}, + "severity": {"readonly": True}, + "error_details": {"readonly": True}, + "detailed_information": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "title": {"key": "properties.title", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "appeared_at_date_time": {"key": "properties.appearedAtDateTime", "type": "iso-8601"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "error_details": {"key": "properties.errorDetails", "type": "AlertErrorDetails"}, + "detailed_information": {"key": "properties.detailedInformation", "type": "{str}"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None self.title = None self.alert_type = None @@ -261,7 +269,7 @@ def __init__( self.detailed_information = None -class AlertErrorDetails(msrest.serialization.Model): +class AlertErrorDetails(_serialization.Model): """Error details for the alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -275,28 +283,26 @@ class AlertErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, + "error_code": {"readonly": True}, + "error_message": {"readonly": True}, + "occurrences": {"readonly": True}, } _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "occurrences": {"key": "occurrences", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_code = None self.error_message = None self.occurrences = None -class AlertList(msrest.serialization.Model): +class AlertList(_serialization.Model): """Collection of alerts. Variables are only populated by the server, and will be ignored when sending a request. @@ -308,25 +314,23 @@ class AlertList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ArcAddon(Addon): +class ArcAddon(Addon): # pylint: disable=too-many-instance-attributes """Arc Addon. Variables are only populated by the server, and will be ignored when sending a request. @@ -339,77 +343,80 @@ class ArcAddon(Addon): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param subscription_id: Required. Arc resource subscription Id. - :type subscription_id: str - :param resource_group_name: Required. Arc resource group name. - :type resource_group_name: str - :param resource_name: Required. Arc resource Name. - :type resource_name: str - :param resource_location: Required. Arc resource location. - :type resource_location: str + :ivar subscription_id: Arc resource subscription Id. Required. + :vartype subscription_id: str + :ivar resource_group_name: Arc resource group name. Required. + :vartype resource_group_name: str + :ivar resource_name: Arc resource Name. Required. + :vartype resource_name: str + :ivar resource_location: Arc resource location. Required. + :vartype resource_location: str :ivar version: Arc resource version. :vartype version: str - :ivar host_platform: Host OS supported by the Arc addon. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the Arc addon. Known values are: "Windows" and "Linux". :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'subscription_id': {'required': True}, - 'resource_group_name': {'required': True}, - 'resource_name': {'required': True}, - 'resource_location': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "subscription_id": {"required": True}, + "resource_group_name": {"required": True}, + "resource_name": {"required": True}, + "resource_location": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'properties.resourceGroupName', 'type': 'str'}, - 'resource_name': {'key': 'properties.resourceName', 'type': 'str'}, - 'resource_location': {'key': 'properties.resourceLocation', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "subscription_id": {"key": "properties.subscriptionId", "type": "str"}, + "resource_group_name": {"key": "properties.resourceGroupName", "type": "str"}, + "resource_name": {"key": "properties.resourceName", "type": "str"}, + "resource_location": {"key": "properties.resourceLocation", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( - self, - *, - subscription_id: str, - resource_group_name: str, - resource_name: str, - resource_location: str, - **kwargs + self, *, subscription_id: str, resource_group_name: str, resource_name: str, resource_location: str, **kwargs ): - super(ArcAddon, self).__init__(**kwargs) - self.kind = 'ArcForKubernetes' # type: str + """ + :keyword subscription_id: Arc resource subscription Id. Required. + :paramtype subscription_id: str + :keyword resource_group_name: Arc resource group name. Required. + :paramtype resource_group_name: str + :keyword resource_name: Arc resource Name. Required. + :paramtype resource_name: str + :keyword resource_location: Arc resource location. Required. + :paramtype resource_location: str + """ + super().__init__(**kwargs) + self.kind: str = "ArcForKubernetes" self.subscription_id = subscription_id self.resource_group_name = resource_group_name self.resource_name = resource_name @@ -420,95 +427,105 @@ def __init__( self.provisioning_state = None -class AsymmetricEncryptedSecret(msrest.serialization.Model): +class AsymmetricEncryptedSecret(_serialization.Model): """Represent the secrets intended for encryption with asymmetric key pair. All required parameters must be populated in order to send to Azure. - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + :ivar value: The value of the secret. Required. + :vartype value: str + :ivar encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or + :vartype encryption_cert_thumbprint: str + :ivar encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values are: + "None", "AES256", and "RSAES_PKCS1_v_1_5". + :vartype encryption_algorithm: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EncryptionAlgorithm """ _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, + "value": {"required": True}, + "encryption_algorithm": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "encryption_cert_thumbprint": {"key": "encryptionCertThumbprint", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, } def __init__( self, *, value: str, - encryption_algorithm: Union[str, "EncryptionAlgorithm"], + encryption_algorithm: Union[str, "_models.EncryptionAlgorithm"], encryption_cert_thumbprint: Optional[str] = None, **kwargs ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) + """ + :keyword value: The value of the secret. Required. + :paramtype value: str + :keyword encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :paramtype encryption_cert_thumbprint: str + :keyword encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values + are: "None", "AES256", and "RSAES_PKCS1_v_1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EncryptionAlgorithm + """ + super().__init__(**kwargs) self.value = value self.encryption_cert_thumbprint = encryption_cert_thumbprint self.encryption_algorithm = encryption_algorithm -class Authentication(msrest.serialization.Model): +class Authentication(_serialization.Model): """Authentication mechanism for IoT devices. - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SymmetricKey + :ivar symmetric_key: Symmetric key for authentication. + :vartype symmetric_key: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SymmetricKey """ _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, + "symmetric_key": {"key": "symmetricKey", "type": "SymmetricKey"}, } - def __init__( - self, - *, - symmetric_key: Optional["SymmetricKey"] = None, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) + def __init__(self, *, symmetric_key: Optional["_models.SymmetricKey"] = None, **kwargs): + """ + :keyword symmetric_key: Symmetric key for authentication. + :paramtype symmetric_key: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SymmetricKey + """ + super().__init__(**kwargs) self.symmetric_key = symmetric_key -class AzureContainerInfo(msrest.serialization.Model): +class AzureContainerInfo(_serialization.Model): """Azure container mapping of the endpoint. All required parameters must be populated in order to send to Azure. - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or + :ivar storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :vartype storage_account_credential_id: str + :ivar container_name: Container name (Based on the data format specified, this represents the + name of Azure Files/Page blob/Block blob). Required. + :vartype container_name: str + :ivar data_format: Storage format used for the file represented by the share. Required. Known + values are: "BlockBlob", "PageBlob", and "AzureFile". + :vartype data_format: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AzureContainerDataFormat """ _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, + "storage_account_credential_id": {"required": True}, + "container_name": {"required": True}, + "data_format": {"required": True}, } _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, + "storage_account_credential_id": {"key": "storageAccountCredentialId", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "data_format": {"key": "dataFormat", "type": "str"}, } def __init__( @@ -516,10 +533,22 @@ def __init__( *, storage_account_credential_id: str, container_name: str, - data_format: Union[str, "AzureContainerDataFormat"], + data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs ): - super(AzureContainerInfo, self).__init__(**kwargs) + """ + :keyword storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :paramtype storage_account_credential_id: str + :keyword container_name: Container name (Based on the data format specified, this represents + the name of Azure Files/Page blob/Block blob). Required. + :paramtype container_name: str + :keyword data_format: Storage format used for the file represented by the share. Required. + Known values are: "BlockBlob", "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.storage_account_credential_id = storage_account_credential_id self.container_name = container_name self.data_format = data_format @@ -540,48 +569,52 @@ class BandwidthSchedule(ARMBaseModel): :vartype type: str :ivar system_data: Bandwidth object related to ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DayOfWeek] + :ivar start: The start time of the schedule in UTC. Required. + :vartype start: str + :ivar stop: The stop time of the schedule in UTC. Required. + :vartype stop: str + :ivar rate_in_mbps: The bandwidth rate in Mbps. Required. + :vartype rate_in_mbps: int + :ivar days: The days of the week when this schedule is applicable. Required. + :vartype days: list[str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DayOfWeek] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "start": {"required": True}, + "stop": {"required": True}, + "rate_in_mbps": {"required": True}, + "days": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "start": {"key": "properties.start", "type": "str"}, + "stop": {"key": "properties.stop", "type": "str"}, + "rate_in_mbps": {"key": "properties.rateInMbps", "type": "int"}, + "days": {"key": "properties.days", "type": "[str]"}, } def __init__( - self, - *, - start: str, - stop: str, - rate_in_mbps: int, - days: List[Union[str, "DayOfWeek"]], - **kwargs + self, *, start: str, stop: str, rate_in_mbps: int, days: List[Union[str, "_models.DayOfWeek"]], **kwargs ): - super(BandwidthSchedule, self).__init__(**kwargs) + """ + :keyword start: The start time of the schedule in UTC. Required. + :paramtype start: str + :keyword stop: The stop time of the schedule in UTC. Required. + :paramtype stop: str + :keyword rate_in_mbps: The bandwidth rate in Mbps. Required. + :paramtype rate_in_mbps: int + :keyword days: The days of the week when this schedule is applicable. Required. + :paramtype days: list[str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DayOfWeek] + """ + super().__init__(**kwargs) self.system_data = None self.start = start self.stop = stop @@ -589,7 +622,7 @@ def __init__( self.days = days -class BandwidthSchedulesList(msrest.serialization.Model): +class BandwidthSchedulesList(_serialization.Model): """The collection of bandwidth schedules. Variables are only populated by the server, and will be ignored when sending a request. @@ -601,55 +634,55 @@ class BandwidthSchedulesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BandwidthSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ClientAccessRight(msrest.serialization.Model): +class ClientAccessRight(_serialization.Model): """The mapping between a particular client IP and the type of access client has on the NFS share. All required parameters must be populated in order to send to Azure. - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or + :ivar client: IP of the client. Required. + :vartype client: str + :ivar access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :vartype access_permission: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ClientPermissionType """ _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, + "client": {"required": True}, + "access_permission": {"required": True}, } _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - *, - client: str, - access_permission: Union[str, "ClientPermissionType"], - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) + "client": {"key": "client", "type": "str"}, + "access_permission": {"key": "accessPermission", "type": "str"}, + } + + def __init__(self, *, client: str, access_permission: Union[str, "_models.ClientPermissionType"], **kwargs): + """ + :keyword client: IP of the client. Required. + :paramtype client: str + :keyword access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :paramtype access_permission: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ClientPermissionType + """ + super().__init__(**kwargs) self.client = client self.access_permission = access_permission @@ -657,8 +690,8 @@ def __init__( class Role(ARMBaseModel): """Compute role. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole Variables are only populated by the server, and will be ignored when sending a request. @@ -670,39 +703,42 @@ class Role(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } _subtype_map = { - 'kind': {'CloudEdgeManagement': 'CloudEdgeManagementRole', 'IOT': 'IoTRole', 'Kubernetes': 'KubernetesRole', 'MEC': 'MECRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str + "kind": { + "CloudEdgeManagement": "CloudEdgeManagementRole", + "IOT": "IoTRole", + "Kubernetes": "KubernetesRole", + "MEC": "MECRole", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None self.system_data = None @@ -719,72 +755,71 @@ class CloudEdgeManagementRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :ivar local_management_status: Local Edge Management Status. Possible values include: - "Enabled", "Disabled". + :ivar local_management_status: Local Edge Management Status. Known values are: "Enabled" and + "Disabled". :vartype local_management_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus :ivar edge_profile: Edge Profile of the resource. :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfile - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'local_management_status': {'readonly': True}, - 'edge_profile': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "local_management_status": {"readonly": True}, + "edge_profile": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'local_management_status': {'key': 'properties.localManagementStatus', 'type': 'str'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - *, - role_status: Optional[Union[str, "RoleStatus"]] = None, - **kwargs - ): - super(CloudEdgeManagementRole, self).__init__(**kwargs) - self.kind = 'CloudEdgeManagement' # type: str + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "local_management_status": {"key": "properties.localManagementStatus", "type": "str"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, + } + + def __init__(self, *, role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs): + """ + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "CloudEdgeManagement" self.local_management_status = None self.edge_profile = None self.role_status = role_status -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.CloudErrorBody] + :vartype message: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.CloudErrorBody] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -792,16 +827,26 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): - super(CloudErrorBody, self).__init__(**kwargs) + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.CloudErrorBody] + """ + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class CniConfig(msrest.serialization.Model): +class CniConfig(_serialization.Model): """Cni configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -817,102 +862,102 @@ class CniConfig(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - 'pod_subnet': {'readonly': True}, - 'service_subnet': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, + "pod_subnet": {"readonly": True}, + "service_subnet": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'pod_subnet': {'key': 'podSubnet', 'type': 'str'}, - 'service_subnet': {'key': 'serviceSubnet', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "pod_subnet": {"key": "podSubnet", "type": "str"}, + "service_subnet": {"key": "serviceSubnet", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(CniConfig, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None self.pod_subnet = None self.service_subnet = None -class ComputeResource(msrest.serialization.Model): +class ComputeResource(_serialization.Model): """Compute infrastructure Resource. All required parameters must be populated in order to send to Azure. - :param processor_count: Required. Processor count. - :type processor_count: int - :param memory_in_gb: Required. Memory in GB. - :type memory_in_gb: long + :ivar processor_count: Processor count. Required. + :vartype processor_count: int + :ivar memory_in_gb: Memory in GB. Required. + :vartype memory_in_gb: int """ _validation = { - 'processor_count': {'required': True}, - 'memory_in_gb': {'required': True}, + "processor_count": {"required": True}, + "memory_in_gb": {"required": True}, } _attribute_map = { - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'long'}, - } - - def __init__( - self, - *, - processor_count: int, - memory_in_gb: int, - **kwargs - ): - super(ComputeResource, self).__init__(**kwargs) + "processor_count": {"key": "processorCount", "type": "int"}, + "memory_in_gb": {"key": "memoryInGB", "type": "int"}, + } + + def __init__(self, *, processor_count: int, memory_in_gb: int, **kwargs): + """ + :keyword processor_count: Processor count. Required. + :paramtype processor_count: int + :keyword memory_in_gb: Memory in GB. Required. + :paramtype memory_in_gb: int + """ + super().__init__(**kwargs) self.processor_count = processor_count self.memory_in_gb = memory_in_gb -class ContactDetails(msrest.serialization.Model): +class ContactDetails(_serialization.Model): """Contains all the contact details of the customer. All required parameters must be populated in order to send to Azure. - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] + :ivar contact_person: The contact person name. Required. + :vartype contact_person: str + :ivar company_name: The name of the company. Required. + :vartype company_name: str + :ivar phone: The phone number. Required. + :vartype phone: str + :ivar email_list: The email list. Required. + :vartype email_list: list[str] """ _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, + "contact_person": {"required": True}, + "company_name": {"required": True}, + "phone": {"required": True}, + "email_list": {"required": True}, } _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - *, - contact_person: str, - company_name: str, - phone: str, - email_list: List[str], - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) + "contact_person": {"key": "contactPerson", "type": "str"}, + "company_name": {"key": "companyName", "type": "str"}, + "phone": {"key": "phone", "type": "str"}, + "email_list": {"key": "emailList", "type": "[str]"}, + } + + def __init__(self, *, contact_person: str, company_name: str, phone: str, email_list: List[str], **kwargs): + """ + :keyword contact_person: The contact person name. Required. + :paramtype contact_person: str + :keyword company_name: The name of the company. Required. + :paramtype company_name: str + :keyword phone: The phone number. Required. + :paramtype phone: str + :keyword email_list: The email list. Required. + :paramtype email_list: list[str] + """ + super().__init__(**kwargs) self.contact_person = contact_person self.company_name = company_name self.phone = phone @@ -934,13 +979,13 @@ class Container(ARMBaseModel): :vartype type: str :ivar system_data: Container in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". + :ivar container_status: Current status of the container. Known values are: "OK", "Offline", + "Unknown", "Updating", and "NeedsAttention". :vartype container_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or + :ivar data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :vartype data_format: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AzureContainerDataFormat :ivar refresh_details: Details of the refresh job on this container. :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RefreshDetails @@ -949,34 +994,35 @@ class Container(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "container_status": {"readonly": True}, + "data_format": {"required": True}, + "refresh_details": {"readonly": True}, + "created_date_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - data_format: Union[str, "AzureContainerDataFormat"], - **kwargs - ): - super(Container, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "container_status": {"key": "properties.containerStatus", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, + } + + def __init__(self, *, data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs): + """ + :keyword data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.system_data = None self.container_status = None self.data_format = data_format @@ -984,7 +1030,7 @@ def __init__( self.created_date_time = None -class ContainerList(msrest.serialization.Model): +class ContainerList(_serialization.Model): """Collection of all the containers on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -996,25 +1042,23 @@ class ContainerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Container]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevice(ARMBaseModel): +class DataBoxEdgeDevice(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1027,29 +1071,29 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure + :ivar location: The location of the device. This is a supported and registered Azure geographical region (for example, West US, East US, or Southeast Asia). The geographical region of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceIdentity - :ivar kind: The etag for the devices. Possible values include: "AzureDataBoxGateway", - "AzureStackEdge", "AzureStackHub", "AzureModularDataCentre". + specified on update, the request will succeed. Required. + :vartype location: str + :ivar tags: The list of tags that describe the device. These tags can be used to view and group + this device (across resource groups). + :vartype tags: dict[str, str] + :ivar sku: The SKU type. + :vartype sku: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Sku + :ivar etag: The etag for the devices. + :vartype etag: str + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceIdentity + :ivar kind: The etag for the devices. Known values are: "AzureDataBoxGateway", + "AzureStackEdge", "AzureStackHub", and "AzureModularDataCentre". :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceKind :ivar system_data: DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or + :ivar data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known values + are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :vartype data_box_edge_device_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceStatus :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. :vartype serial_number: str @@ -1057,8 +1101,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype description: str :ivar model_description: The description of the Data Box Edge/Gateway device model. :vartype model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". + :ivar device_type: The type of the Data Box Edge/Gateway device. "DataBoxEdgeDevice" :vartype device_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DeviceType :ivar friendly_name: The Data Box Edge/Gateway device name. :vartype friendly_name: str @@ -1069,7 +1112,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :ivar device_software_version: The Data Box Edge/Gateway device software version. :vartype device_software_version: str :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long + :vartype device_local_capacity: int :ivar time_zone: The Data Box Edge/Gateway device timezone. :vartype time_zone: str :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). @@ -1087,70 +1130,91 @@ class DataBoxEdgeDevice(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'system_data': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'description': {'readonly': True}, - 'model_description': {'readonly': True}, - 'device_type': {'readonly': True}, - 'friendly_name': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'edge_profile': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"readonly": True}, + "system_data": {"readonly": True}, + "serial_number": {"readonly": True}, + "description": {"readonly": True}, + "model_description": {"readonly": True}, + "device_type": {"readonly": True}, + "friendly_name": {"readonly": True}, + "culture": {"readonly": True}, + "device_model": {"readonly": True}, + "device_software_version": {"readonly": True}, + "device_local_capacity": {"readonly": True}, + "time_zone": {"readonly": True}, + "device_hcs_version": {"readonly": True}, + "configured_role_types": {"readonly": True}, + "node_count": {"readonly": True}, + "resource_move_details": {"readonly": True}, + "edge_profile": {"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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - 'resource_move_details': {'key': 'properties.resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - } - - def __init__( + "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}"}, + "sku": {"key": "sku", "type": "Sku"}, + "etag": {"key": "etag", "type": "str"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "data_box_edge_device_status": {"key": "properties.dataBoxEdgeDeviceStatus", "type": "str"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "model_description": {"key": "properties.modelDescription", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "culture": {"key": "properties.culture", "type": "str"}, + "device_model": {"key": "properties.deviceModel", "type": "str"}, + "device_software_version": {"key": "properties.deviceSoftwareVersion", "type": "str"}, + "device_local_capacity": {"key": "properties.deviceLocalCapacity", "type": "int"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "device_hcs_version": {"key": "properties.deviceHcsVersion", "type": "str"}, + "configured_role_types": {"key": "properties.configuredRoleTypes", "type": "[str]"}, + "node_count": {"key": "properties.nodeCount", "type": "int"}, + "resource_move_details": {"key": "properties.resourceMoveDetails", "type": "ResourceMoveDetails"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, etag: Optional[str] = None, - identity: Optional["ResourceIdentity"] = None, - data_box_edge_device_status: Optional[Union[str, "DataBoxEdgeDeviceStatus"]] = None, + identity: Optional["_models.ResourceIdentity"] = None, + data_box_edge_device_status: Optional[Union[str, "_models.DataBoxEdgeDeviceStatus"]] = None, **kwargs ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) + """ + :keyword location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :paramtype location: str + :keyword tags: The list of tags that describe the device. These tags can be used to view and + group this device (across resource groups). + :paramtype tags: dict[str, str] + :keyword sku: The SKU type. + :paramtype sku: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Sku + :keyword etag: The etag for the devices. + :paramtype etag: str + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceIdentity + :keyword data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known + values are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :paramtype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceStatus + """ + super().__init__(**kwargs) self.location = location self.tags = tags self.sku = sku @@ -1187,43 +1251,43 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to + :ivar encryption_key_thumbprint: The digital signature of encrypted certificate. + :vartype encryption_key_thumbprint: str + :ivar encryption_key: The public part of the encryption certificate. Client uses this to encrypt any secret. - :type encryption_key: str + :vartype encryption_key: str :ivar resource_key: The Resource ID of the Resource. :vartype resource_key: str - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_version: str + :vartype channel_integrity_key_version: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_key": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - 'client_secret_store_id': {'key': 'properties.clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'properties.clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'properties.channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'properties.channelIntegrityKeyVersion', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encryption_key_thumbprint": {"key": "properties.encryptionKeyThumbprint", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "str"}, + "resource_key": {"key": "properties.resourceKey", "type": "str"}, + "client_secret_store_id": {"key": "properties.clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "properties.clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "properties.channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "properties.channelIntegrityKeyVersion", "type": "str"}, } def __init__( @@ -1237,7 +1301,24 @@ def __init__( channel_integrity_key_version: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) + """ + :keyword encryption_key_thumbprint: The digital signature of encrypted certificate. + :paramtype encryption_key_thumbprint: str + :keyword encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :paramtype encryption_key: str + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + """ + super().__init__(**kwargs) self.encryption_key_thumbprint = encryption_key_thumbprint self.encryption_key = encryption_key self.resource_key = None @@ -1247,26 +1328,26 @@ def __init__( self.channel_integrity_key_version = channel_integrity_key_version -class DataBoxEdgeDeviceExtendedInfoPatch(msrest.serialization.Model): +class DataBoxEdgeDeviceExtendedInfoPatch(_serialization.Model): """The Data Box Edge/Gateway device extended info patch. - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_version: str + :vartype channel_integrity_key_version: str """ _attribute_map = { - 'client_secret_store_id': {'key': 'clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'channelIntegrityKeyVersion', 'type': 'str'}, + "client_secret_store_id": {"key": "clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "channelIntegrityKeyVersion", "type": "str"}, } def __init__( @@ -1278,14 +1359,26 @@ def __init__( channel_integrity_key_version: Optional[str] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfoPatch, self).__init__(**kwargs) + """ + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name for Channel Integrity Key stored in the Client + Key Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + """ + super().__init__(**kwargs) self.client_secret_store_id = client_secret_store_id self.client_secret_store_url = client_secret_store_url self.channel_integrity_key_name = channel_integrity_key_name self.channel_integrity_key_version = channel_integrity_key_version -class DataBoxEdgeDeviceList(msrest.serialization.Model): +class DataBoxEdgeDeviceList(_serialization.Model): """The collection of Data Box Edge/Gateway devices. Variables are only populated by the server, and will be ignored when sending a request. @@ -1297,103 +1390,109 @@ class DataBoxEdgeDeviceList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevicePatch(msrest.serialization.Model): +class DataBoxEdgeDevicePatch(_serialization.Model): """The Data Box Edge/Gateway device patch. - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceIdentity - :param edge_profile: Edge Profile property of the Data Box Edge/Gateway device. - :type edge_profile: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfilePatch + :ivar tags: The tags attached to the Data Box Edge/Gateway resource. + :vartype tags: dict[str, str] + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceIdentity + :ivar edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :vartype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfilePatch """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfilePatch'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfilePatch"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["ResourceIdentity"] = None, - edge_profile: Optional["EdgeProfilePatch"] = None, + identity: Optional["_models.ResourceIdentity"] = None, + edge_profile: Optional["_models.EdgeProfilePatch"] = None, **kwargs ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) + """ + :keyword tags: The tags attached to the Data Box Edge/Gateway resource. + :paramtype tags: dict[str, str] + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceIdentity + :keyword edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :paramtype edge_profile: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfilePatch + """ + super().__init__(**kwargs) self.tags = tags self.identity = identity self.edge_profile = edge_profile -class DataBoxEdgeMoveRequest(msrest.serialization.Model): +class DataBoxEdgeMoveRequest(_serialization.Model): """Resource Move details. All required parameters must be populated in order to send to Azure. - :param target_resource_group: Required. Target resource group ARMId. - :type target_resource_group: str - :param resources: Required. List of resources to be moved. - :type resources: list[str] + :ivar target_resource_group: Target resource group ARMId. Required. + :vartype target_resource_group: str + :ivar resources: List of resources to be moved. Required. + :vartype resources: list[str] """ _validation = { - 'target_resource_group': {'required': True}, - 'resources': {'required': True}, + "target_resource_group": {"required": True}, + "resources": {"required": True}, } _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[str]'}, - } - - def __init__( - self, - *, - target_resource_group: str, - resources: List[str], - **kwargs - ): - super(DataBoxEdgeMoveRequest, self).__init__(**kwargs) + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, + "resources": {"key": "resources", "type": "[str]"}, + } + + def __init__(self, *, target_resource_group: str, resources: List[str], **kwargs): + """ + :keyword target_resource_group: Target resource group ARMId. Required. + :paramtype target_resource_group: str + :keyword resources: List of resources to be moved. Required. + :paramtype resources: list[str] + """ + super().__init__(**kwargs) self.target_resource_group = target_resource_group self.resources = resources -class DataBoxEdgeSku(msrest.serialization.Model): +class DataBoxEdgeSku(_serialization.Model): # pylint: disable=too-many-instance-attributes """The Sku information. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". + :ivar name: The Sku name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", and "RDC". :vartype name: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuName :ivar kind: The Sku kind. :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". + :ivar tier: The Sku tier. "Standard" :vartype tier: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuTier :ivar size: The Sku kind. :vartype size: str @@ -1408,14 +1507,14 @@ class DataBoxEdgeSku(msrest.serialization.Model): list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuLocationInfo] :ivar costs: The pricing info of the Sku. :vartype costs: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuCost] - :ivar signup_option: Sku can be signed up by customer or not. Possible values include: "None", + :ivar signup_option: Sku can be signed up by customer or not. Known values are: "None" and "Available". :vartype signup_option: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuSignupOption - :ivar version: Availability of the Sku as preview/stable. Possible values include: "Stable", + :ivar version: Availability of the Sku as preview/stable. Known values are: "Stable" and "Preview". :vartype version: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuVersion - :ivar availability: Links to the next set of results. Possible values include: "Available", + :ivar availability: Links to the next set of results. Known values are: "Available" and "Unavailable". :vartype availability: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuAvailability @@ -1425,44 +1524,42 @@ class DataBoxEdgeSku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - 'shipment_types': {'readonly': True}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "kind": {"readonly": True}, + "tier": {"readonly": True}, + "size": {"readonly": True}, + "family": {"readonly": True}, + "locations": {"readonly": True}, + "api_versions": {"readonly": True}, + "location_info": {"readonly": True}, + "costs": {"readonly": True}, + "signup_option": {"readonly": True}, + "version": {"readonly": True}, + "availability": {"readonly": True}, + "shipment_types": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, - 'shipment_types': {'key': 'shipmentTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "signup_option": {"key": "signupOption", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "availability": {"key": "availability", "type": "str"}, + "shipment_types": {"key": "shipmentTypes", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.kind = None @@ -1479,7 +1576,7 @@ def __init__( self.shipment_types = None -class DataBoxEdgeSkuList(msrest.serialization.Model): +class DataBoxEdgeSkuList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -1491,144 +1588,166 @@ class DataBoxEdgeSkuList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DCAccessCode(msrest.serialization.Model): +class DCAccessCode(_serialization.Model): """DC Access code in the case of Self Managed Shipping. - :param auth_code: DCAccess Code for the Self Managed shipment. - :type auth_code: str + :ivar auth_code: DCAccess Code for the Self Managed shipment. + :vartype auth_code: str """ _attribute_map = { - 'auth_code': {'key': 'properties.authCode', 'type': 'str'}, + "auth_code": {"key": "properties.authCode", "type": "str"}, } - def __init__( - self, - *, - auth_code: Optional[str] = None, - **kwargs - ): - super(DCAccessCode, self).__init__(**kwargs) + def __init__(self, *, auth_code: Optional[str] = None, **kwargs): + """ + :keyword auth_code: DCAccess Code for the Self Managed shipment. + :paramtype auth_code: str + """ + super().__init__(**kwargs) self.auth_code = auth_code -class EdgeProfile(msrest.serialization.Model): +class EdgeProfile(_serialization.Model): """Details about Edge Profile for the resource. - :param subscription: Edge Profile Subscription. - :type subscription: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfileSubscription + :ivar subscription: Edge Profile Subscription. + :vartype subscription: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfileSubscription """ _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscription'}, + "subscription": {"key": "subscription", "type": "EdgeProfileSubscription"}, } - def __init__( - self, - *, - subscription: Optional["EdgeProfileSubscription"] = None, - **kwargs - ): - super(EdgeProfile, self).__init__(**kwargs) + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscription"] = None, **kwargs): + """ + :keyword subscription: Edge Profile Subscription. + :paramtype subscription: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfileSubscription + """ + super().__init__(**kwargs) self.subscription = subscription -class EdgeProfilePatch(msrest.serialization.Model): +class EdgeProfilePatch(_serialization.Model): """The Data Box Edge/Gateway Edge Profile patch. - :param subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. - :type subscription: + :ivar subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :vartype subscription: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfileSubscriptionPatch """ _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscriptionPatch'}, + "subscription": {"key": "subscription", "type": "EdgeProfileSubscriptionPatch"}, } - def __init__( - self, - *, - subscription: Optional["EdgeProfileSubscriptionPatch"] = None, - **kwargs - ): - super(EdgeProfilePatch, self).__init__(**kwargs) + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscriptionPatch"] = None, **kwargs): + """ + :keyword subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :paramtype subscription: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EdgeProfileSubscriptionPatch + """ + super().__init__(**kwargs) self.subscription = subscription -class EdgeProfileSubscription(msrest.serialization.Model): +class EdgeProfileSubscription(_serialization.Model): """Subscription details for the Edge Profile. - :param registration_id: Edge Subscription Registration ID. - :type registration_id: str - :param id: ARM ID of the subscription. - :type id: str - :param state: Possible values include: "Registered", "Warned", "Suspended", "Deleted", + :ivar registration_id: Edge Subscription Registration ID. + :vartype registration_id: str + :ivar id: ARM ID of the subscription. + :vartype id: str + :ivar state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and "Unregistered". - :type state: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SubscriptionState - :param registration_date: - :type registration_date: str - :param subscription_id: - :type subscription_id: str - :param tenant_id: - :type tenant_id: str - :param location_placement_id: - :type location_placement_id: str - :param quota_id: - :type quota_id: str - :param serialized_details: - :type serialized_details: str - :param registered_features: - :type registered_features: + :vartype state: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SubscriptionState + :ivar registration_date: + :vartype registration_date: str + :ivar subscription_id: + :vartype subscription_id: str + :ivar tenant_id: + :vartype tenant_id: str + :ivar location_placement_id: + :vartype location_placement_id: str + :ivar quota_id: + :vartype quota_id: str + :ivar serialized_details: + :vartype serialized_details: str + :ivar registered_features: + :vartype registered_features: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SubscriptionRegisteredFeatures] """ _attribute_map = { - 'registration_id': {'key': 'registrationId', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'registration_date': {'key': 'registrationDate', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'location_placement_id': {'key': 'properties.locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'properties.quotaId', 'type': 'str'}, - 'serialized_details': {'key': 'properties.serializedDetails', 'type': 'str'}, - 'registered_features': {'key': 'properties.registeredFeatures', 'type': '[SubscriptionRegisteredFeatures]'}, + "registration_id": {"key": "registrationId", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "registration_date": {"key": "registrationDate", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "location_placement_id": {"key": "properties.locationPlacementId", "type": "str"}, + "quota_id": {"key": "properties.quotaId", "type": "str"}, + "serialized_details": {"key": "properties.serializedDetails", "type": "str"}, + "registered_features": {"key": "properties.registeredFeatures", "type": "[SubscriptionRegisteredFeatures]"}, } def __init__( self, *, registration_id: Optional[str] = None, - id: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + state: Optional[Union[str, "_models.SubscriptionState"]] = None, registration_date: Optional[str] = None, subscription_id: Optional[str] = None, tenant_id: Optional[str] = None, location_placement_id: Optional[str] = None, quota_id: Optional[str] = None, serialized_details: Optional[str] = None, - registered_features: Optional[List["SubscriptionRegisteredFeatures"]] = None, + registered_features: Optional[List["_models.SubscriptionRegisteredFeatures"]] = None, **kwargs ): - super(EdgeProfileSubscription, self).__init__(**kwargs) + """ + :keyword registration_id: Edge Subscription Registration ID. + :paramtype registration_id: str + :keyword id: ARM ID of the subscription. + :paramtype id: str + :keyword state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and + "Unregistered". + :paramtype state: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SubscriptionState + :keyword registration_date: + :paramtype registration_date: str + :keyword subscription_id: + :paramtype subscription_id: str + :keyword tenant_id: + :paramtype tenant_id: str + :keyword location_placement_id: + :paramtype location_placement_id: str + :keyword quota_id: + :paramtype quota_id: str + :keyword serialized_details: + :paramtype serialized_details: str + :keyword registered_features: + :paramtype registered_features: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.SubscriptionRegisteredFeatures] + """ + super().__init__(**kwargs) self.registration_id = registration_id self.id = id self.state = state @@ -1641,28 +1760,27 @@ def __init__( self.registered_features = registered_features -class EdgeProfileSubscriptionPatch(msrest.serialization.Model): +class EdgeProfileSubscriptionPatch(_serialization.Model): """The Data Box Edge/Gateway Edge Profile Subscription patch. - :param id: The path ID that uniquely identifies the subscription of the edge profile. - :type id: str + :ivar id: The path ID that uniquely identifies the subscription of the edge profile. + :vartype id: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): - super(EdgeProfileSubscriptionPatch, self).__init__(**kwargs) + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The path ID that uniquely identifies the subscription of the edge profile. + :paramtype id: str + """ + super().__init__(**kwargs) self.id = id -class EtcdInfo(msrest.serialization.Model): +class EtcdInfo(_serialization.Model): """Etcd configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1674,20 +1792,18 @@ class EtcdInfo(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(EtcdInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None @@ -1695,8 +1811,8 @@ def __init__( class Trigger(ARMBaseModel): """Trigger details. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FileEventTrigger, PeriodicTimerEventTrigger Variables are only populated by the server, and will be ignored when sending a request. @@ -1710,38 +1826,33 @@ class Trigger(ARMBaseModel): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerEventType + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerEventType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } + _subtype_map = {"kind": {"FileEvent": "FileEventTrigger", "PeriodicTimerEvent": "PeriodicTimerEventTrigger"}} - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None - self.kind = 'Trigger' # type: str + self.kind: Optional[str] = None class FileEventTrigger(Trigger): @@ -1759,100 +1870,108 @@ class FileEventTrigger(Trigger): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerEventType + :ivar source_info: File event source details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.FileSourceInfo + :ivar sink_info: Role sink info. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "FileSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "FileSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.FileSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str + """ + :keyword source_info: File event source details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.FileSourceInfo + :keyword sink_info: Role sink info. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "FileEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class FileSourceInfo(msrest.serialization.Model): +class FileSourceInfo(_serialization.Model): """File source details. All required parameters must be populated in order to send to Azure. - :param share_id: Required. File share ID. - :type share_id: str + :ivar share_id: File share ID. Required. + :vartype share_id: str """ _validation = { - 'share_id': {'required': True}, + "share_id": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: File share ID. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id -class GenerateCertResponse(msrest.serialization.Model): +class GenerateCertResponse(_serialization.Model): """Used in activation key generation flow. - :param public_key: Gets or sets base64 encoded certificate raw data, + :ivar public_key: Gets or sets base64 encoded certificate raw data, this is the public part needed to be uploaded to cert vault. - :type public_key: str - :param private_key: Gets or sets base64 encoded private part of the certificate, + :vartype public_key: str + :ivar private_key: Gets or sets base64 encoded private part of the certificate, needed to form the activation key. - :type private_key: str - :param expiry_time_in_utc: Gets or sets expiry time in UTC. - :type expiry_time_in_utc: str + :vartype private_key: str + :ivar expiry_time_in_utc: Gets or sets expiry time in UTC. + :vartype expiry_time_in_utc: str """ _attribute_map = { - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'expiry_time_in_utc': {'key': 'expiryTimeInUTC', 'type': 'str'}, + "public_key": {"key": "publicKey", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "expiry_time_in_utc": {"key": "expiryTimeInUTC", "type": "str"}, } def __init__( @@ -1863,34 +1982,44 @@ def __init__( expiry_time_in_utc: Optional[str] = None, **kwargs ): - super(GenerateCertResponse, self).__init__(**kwargs) + """ + :keyword public_key: Gets or sets base64 encoded certificate raw data, + this is the public part needed to be uploaded to cert vault. + :paramtype public_key: str + :keyword private_key: Gets or sets base64 encoded private part of the certificate, + needed to form the activation key. + :paramtype private_key: str + :keyword expiry_time_in_utc: Gets or sets expiry time in UTC. + :paramtype expiry_time_in_utc: str + """ + super().__init__(**kwargs) self.public_key = public_key self.private_key = private_key self.expiry_time_in_utc = expiry_time_in_utc -class ImageRepositoryCredential(msrest.serialization.Model): +class ImageRepositoryCredential(_serialization.Model): """Image repository credential. All required parameters must be populated in order to send to Azure. - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret + :ivar image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :vartype image_repository_url: str + :ivar user_name: Repository user name. Required. + :vartype user_name: str + :ivar password: Repository user password. + :vartype password: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret """ _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, + "image_repository_url": {"required": True}, + "user_name": {"required": True}, } _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, + "image_repository_url": {"key": "imageRepositoryUrl", "type": "str"}, + "user_name": {"key": "userName", "type": "str"}, + "password": {"key": "password", "type": "AsymmetricEncryptedSecret"}, } def __init__( @@ -1898,16 +2027,25 @@ def __init__( *, image_repository_url: str, user_name: str, - password: Optional["AsymmetricEncryptedSecret"] = None, + password: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs ): - super(ImageRepositoryCredential, self).__init__(**kwargs) + """ + :keyword image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :paramtype image_repository_url: str + :keyword user_name: Repository user name. Required. + :paramtype user_name: str + :keyword password: Repository user password. + :paramtype password: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.image_repository_url = image_repository_url self.user_name = user_name self.password = password -class IoTAddon(Addon): +class IoTAddon(Addon): # pylint: disable=too-many-instance-attributes """IoT Addon. Variables are only populated by the server, and will be ignored when sending a request. @@ -1920,70 +2058,79 @@ class IoTAddon(Addon): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param io_t_device_details: Required. IoT device metadata to which appliance needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: Required. IoT edge device to which the IoT Addon needs to be - configured. - :type io_t_edge_device_details: + :ivar io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be configured. + Required. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo :ivar version: Version of IoT running on the appliance. :vartype version: str - :ivar host_platform: Host OS supported by the IoT addon. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the IoT addon. Known values are: "Windows" and "Linux". :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'io_t_device_details': {'required': True}, - 'io_t_edge_device_details': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "io_t_device_details": {"required": True}, + "io_t_edge_device_details": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - io_t_device_details: "IoTDeviceInfo", - io_t_edge_device_details: "IoTDeviceInfo", + io_t_device_details: "_models.IoTDeviceInfo", + io_t_edge_device_details: "_models.IoTDeviceInfo", **kwargs ): - super(IoTAddon, self).__init__(**kwargs) - self.kind = 'IotEdge' # type: str + """ + :keyword io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :paramtype io_t_device_details: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be + configured. Required. + :paramtype io_t_edge_device_details: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo + """ + super().__init__(**kwargs) + self.kind: str = "IotEdge" self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details self.version = None @@ -1992,31 +2139,31 @@ def __init__( self.provisioning_state = None -class IoTDeviceInfo(msrest.serialization.Model): +class IoTDeviceInfo(_serialization.Model): """Metadata of IoT device/IoT Edge device to be configured. All required parameters must be populated in order to send to Azure. - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Authentication + :ivar device_id: ID of the IoT device/edge device. Required. + :vartype device_id: str + :ivar io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :vartype io_t_host_hub: str + :ivar io_t_host_hub_id: Id for the IoT hub associated to the device. + :vartype io_t_host_hub_id: str + :ivar authentication: Encrypted IoT device/IoT edge device connection string. + :vartype authentication: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Authentication """ _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, + "device_id": {"required": True}, + "io_t_host_hub": {"required": True}, } _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, + "device_id": {"key": "deviceId", "type": "str"}, + "io_t_host_hub": {"key": "ioTHostHub", "type": "str"}, + "io_t_host_hub_id": {"key": "ioTHostHubId", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, } def __init__( @@ -2025,39 +2172,49 @@ def __init__( device_id: str, io_t_host_hub: str, io_t_host_hub_id: Optional[str] = None, - authentication: Optional["Authentication"] = None, + authentication: Optional["_models.Authentication"] = None, **kwargs ): - super(IoTDeviceInfo, self).__init__(**kwargs) + """ + :keyword device_id: ID of the IoT device/edge device. Required. + :paramtype device_id: str + :keyword io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :paramtype io_t_host_hub: str + :keyword io_t_host_hub_id: Id for the IoT hub associated to the device. + :paramtype io_t_host_hub_id: str + :keyword authentication: Encrypted IoT device/IoT edge device connection string. + :paramtype authentication: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Authentication + """ + super().__init__(**kwargs) self.device_id = device_id self.io_t_host_hub = io_t_host_hub self.io_t_host_hub_id = io_t_host_hub_id self.authentication = authentication -class IoTEdgeAgentInfo(msrest.serialization.Model): +class IoTEdgeAgentInfo(_serialization.Model): """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. All required parameters must be populated in order to send to Azure. - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: + :ivar image_name: Name of the IoT edge agent image. Required. + :vartype image_name: str + :ivar tag: Image Tag. Required. + :vartype tag: str + :ivar image_repository: Image repository details. + :vartype image_repository: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ImageRepositoryCredential """ _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, + "image_name": {"required": True}, + "tag": {"required": True}, } _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, + "image_name": {"key": "imageName", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "image_repository": {"key": "imageRepository", "type": "ImageRepositoryCredential"}, } def __init__( @@ -2065,16 +2222,25 @@ def __init__( *, image_name: str, tag: str, - image_repository: Optional["ImageRepositoryCredential"] = None, + image_repository: Optional["_models.ImageRepositoryCredential"] = None, **kwargs ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) + """ + :keyword image_name: Name of the IoT edge agent image. Required. + :paramtype image_name: str + :keyword tag: Image Tag. Required. + :paramtype tag: str + :keyword image_repository: Image repository details. + :paramtype image_repository: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ImageRepositoryCredential + """ + super().__init__(**kwargs) self.image_name = image_name self.tag = tag self.image_repository = image_repository -class IoTRole(Role): +class IoTRole(Role): # pylint: disable=too-many-instance-attributes """Compute role. Variables are only populated by the server, and will be ignored when sending a request. @@ -2087,74 +2253,100 @@ class IoTRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the IoT role. Known values are: "Windows" and "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType + :ivar io_t_device_details: IoT device metadata to which data box edge device needs to be connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + :ivar share_mappings: Mount points of shares in role(s). + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] + :ivar io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :vartype io_t_edge_agent_info: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTEdgeAgentInfo + :ivar host_platform_type: Platform where the Iot runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.HostPlatformType - :param compute_resource: Resource allocation. - :type compute_resource: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ComputeResource - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus + :ivar compute_resource: Resource allocation. + :vartype compute_resource: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ComputeResource + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'host_platform_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "host_platform_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'compute_resource': {'key': 'properties.computeResource', 'type': 'ComputeResource'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "io_t_edge_agent_info": {"key": "properties.ioTEdgeAgentInfo", "type": "IoTEdgeAgentInfo"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "compute_resource": {"key": "properties.computeResource", "type": "ComputeResource"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - io_t_device_details: Optional["IoTDeviceInfo"] = None, - io_t_edge_device_details: Optional["IoTDeviceInfo"] = None, - share_mappings: Optional[List["MountPointMap"]] = None, - io_t_edge_agent_info: Optional["IoTEdgeAgentInfo"] = None, - compute_resource: Optional["ComputeResource"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + io_t_device_details: Optional["_models.IoTDeviceInfo"] = None, + io_t_edge_device_details: Optional["_models.IoTDeviceInfo"] = None, + share_mappings: Optional[List["_models.MountPointMap"]] = None, + io_t_edge_agent_info: Optional["_models.IoTEdgeAgentInfo"] = None, + compute_resource: Optional["_models.ComputeResource"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str + """ + :keyword host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :paramtype host_platform: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType + :keyword io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :paramtype io_t_device_details: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT role needs to be + configured. + :paramtype io_t_edge_device_details: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTDeviceInfo + :keyword share_mappings: Mount points of shares in role(s). + :paramtype share_mappings: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] + :keyword io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + runtime. + :paramtype io_t_edge_agent_info: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.IoTEdgeAgentInfo + :keyword compute_resource: Resource allocation. + :paramtype compute_resource: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ComputeResource + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "IOT" self.host_platform = host_platform self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details @@ -2165,7 +2357,7 @@ def __init__( self.role_status = role_status -class Ipv4Config(msrest.serialization.Model): +class Ipv4Config(_serialization.Model): """Details related to the IPv4 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2179,28 +2371,26 @@ class Ipv4Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "subnet": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.subnet = None self.gateway = None -class Ipv6Config(msrest.serialization.Model): +class Ipv6Config(_serialization.Model): """Details related to the IPv6 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2214,28 +2404,26 @@ class Ipv6Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "prefix_length": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "int"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.prefix_length = None self.gateway = None -class Job(msrest.serialization.Model): +class Job(_serialization.Model): # pylint: disable=too-many-instance-attributes """A device job. Variables are only populated by the server, and will be ignored when sending a request. @@ -2246,8 +2434,8 @@ class Job(msrest.serialization.Model): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar status: The current status of the job. Known values are: "Invalid", "Running", + "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.JobStatus :ivar start_time: The UTC date and time at which the job started. :vartype start_time: ~datetime.datetime @@ -2257,14 +2445,14 @@ class Job(msrest.serialization.Model): :vartype percent_complete: int :ivar error: The error details. :vartype error: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", + :ivar job_type: The type of the job. Known values are: "Invalid", "ScanForUpdates", "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer", "Backup", "Restore", - "TriggerSupportPackage". + and "TriggerSupportPackage". :vartype job_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", + :ivar current_stage: Current stage of the update operation. Known values are: "Unknown", "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". + "Success", "Failure", "RescanStarted", "RescanComplete", and "RescanFailed". :vartype current_stage: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UpdateOperationStage :ivar download_progress: The download progress. @@ -2280,55 +2468,55 @@ class Job(msrest.serialization.Model): :vartype error_manifest_file: str :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str + :ivar folder: If only subfolders need to be refreshed, then the subfolder path inside the share + or container. (The path is empty if there are no subfolders.). + :vartype folder: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "error": {"readonly": True}, + "job_type": {"readonly": True}, + "current_stage": {"readonly": True}, + "download_progress": {"readonly": True}, + "install_progress": {"readonly": True}, + "total_refresh_errors": {"readonly": True}, + "error_manifest_file": {"readonly": True}, + "refreshed_entity_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - *, - folder: Optional[str] = None, - **kwargs - ): - super(Job, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "error": {"key": "error", "type": "JobErrorDetails"}, + "job_type": {"key": "properties.jobType", "type": "str"}, + "current_stage": {"key": "properties.currentStage", "type": "str"}, + "download_progress": {"key": "properties.downloadProgress", "type": "UpdateDownloadProgress"}, + "install_progress": {"key": "properties.installProgress", "type": "UpdateInstallProgress"}, + "total_refresh_errors": {"key": "properties.totalRefreshErrors", "type": "int"}, + "error_manifest_file": {"key": "properties.errorManifestFile", "type": "str"}, + "refreshed_entity_id": {"key": "properties.refreshedEntityId", "type": "str"}, + "folder": {"key": "properties.folder", "type": "str"}, + } + + def __init__(self, *, folder: Optional[str] = None, **kwargs): + """ + :keyword folder: If only subfolders need to be refreshed, then the subfolder path inside the + share or container. (The path is empty if there are no subfolders.). + :paramtype folder: str + """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2347,7 +2535,7 @@ def __init__( self.folder = folder -class JobErrorDetails(msrest.serialization.Model): +class JobErrorDetails(_serialization.Model): """The job error information containing the list of job errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -2361,28 +2549,26 @@ class JobErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "error_details": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "error_details": {"key": "errorDetails", "type": "[JobErrorItem]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_details = None self.code = None self.message = None -class JobErrorItem(msrest.serialization.Model): +class JobErrorItem(_serialization.Model): """The job error items. Variables are only populated by the server, and will be ignored when sending a request. @@ -2396,28 +2582,26 @@ class JobErrorItem(msrest.serialization.Model): """ _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "recommendations": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "recommendations": {"key": "recommendations", "type": "[str]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.recommendations = None self.code = None self.message = None -class KubernetesClusterInfo(msrest.serialization.Model): +class KubernetesClusterInfo(_serialization.Model): """Kubernetes cluster configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2428,66 +2612,64 @@ class KubernetesClusterInfo(msrest.serialization.Model): :vartype etcd_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.EtcdInfo :ivar nodes: Kubernetes cluster nodes. :vartype nodes: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.NodeInfo] - :param version: Required. Kubernetes cluster version. - :type version: str + :ivar version: Kubernetes cluster version. Required. + :vartype version: str """ _validation = { - 'etcd_info': {'readonly': True}, - 'nodes': {'readonly': True}, - 'version': {'required': True}, + "etcd_info": {"readonly": True}, + "nodes": {"readonly": True}, + "version": {"required": True}, } _attribute_map = { - 'etcd_info': {'key': 'etcdInfo', 'type': 'EtcdInfo'}, - 'nodes': {'key': 'nodes', 'type': '[NodeInfo]'}, - 'version': {'key': 'version', 'type': 'str'}, + "etcd_info": {"key": "etcdInfo", "type": "EtcdInfo"}, + "nodes": {"key": "nodes", "type": "[NodeInfo]"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - *, - version: str, - **kwargs - ): - super(KubernetesClusterInfo, self).__init__(**kwargs) + def __init__(self, *, version: str, **kwargs): + """ + :keyword version: Kubernetes cluster version. Required. + :paramtype version: str + """ + super().__init__(**kwargs) self.etcd_info = None self.nodes = None self.version = version -class KubernetesIPConfiguration(msrest.serialization.Model): +class KubernetesIPConfiguration(_serialization.Model): """Kubernetes node IP configuration. Variables are only populated by the server, and will be ignored when sending a request. :ivar port: Port of the Kubernetes node. :vartype port: str - :param ip_address: IP address of the Kubernetes node. - :type ip_address: str + :ivar ip_address: IP address of the Kubernetes node. + :vartype ip_address: str """ _validation = { - 'port': {'readonly': True}, + "port": {"readonly": True}, } _attribute_map = { - 'port': {'key': 'port', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + "port": {"key": "port", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, } - def __init__( - self, - *, - ip_address: Optional[str] = None, - **kwargs - ): - super(KubernetesIPConfiguration, self).__init__(**kwargs) + def __init__(self, *, ip_address: Optional[str] = None, **kwargs): + """ + :keyword ip_address: IP address of the Kubernetes node. + :paramtype ip_address: str + """ + super().__init__(**kwargs) self.port = None self.ip_address = ip_address -class KubernetesRole(Role): +class KubernetesRole(Role): # pylint: disable=too-many-instance-attributes """Kubernetes role. Variables are only populated by the server, and will be ignored when sending a request. @@ -2500,67 +2682,81 @@ class KubernetesRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param host_platform: Host OS supported by the Kubernetes role. Possible values include: - "Windows", "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType - :ivar provisioning_state: State of Kubernetes deployment. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" and + "Linux". + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType + :ivar provisioning_state: State of Kubernetes deployment. Known values are: "Invalid", + "Creating", "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesState - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.HostPlatformType - :param kubernetes_cluster_info: Kubernetes cluster configuration. - :type kubernetes_cluster_info: + :ivar kubernetes_cluster_info: Kubernetes cluster configuration. + :vartype kubernetes_cluster_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesClusterInfo - :param kubernetes_role_resources: Kubernetes role resources. - :type kubernetes_role_resources: + :ivar kubernetes_role_resources: Kubernetes role resources. + :vartype kubernetes_role_resources: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleResources - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'host_platform_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "host_platform_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'kubernetes_cluster_info': {'key': 'properties.kubernetesClusterInfo', 'type': 'KubernetesClusterInfo'}, - 'kubernetes_role_resources': {'key': 'properties.kubernetesRoleResources', 'type': 'KubernetesRoleResources'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "kubernetes_cluster_info": {"key": "properties.kubernetesClusterInfo", "type": "KubernetesClusterInfo"}, + "kubernetes_role_resources": {"key": "properties.kubernetesRoleResources", "type": "KubernetesRoleResources"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - kubernetes_cluster_info: Optional["KubernetesClusterInfo"] = None, - kubernetes_role_resources: Optional["KubernetesRoleResources"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + kubernetes_cluster_info: Optional["_models.KubernetesClusterInfo"] = None, + kubernetes_role_resources: Optional["_models.KubernetesRoleResources"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(KubernetesRole, self).__init__(**kwargs) - self.kind = 'Kubernetes' # type: str + """ + :keyword host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" + and "Linux". + :paramtype host_platform: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PlatformType + :keyword kubernetes_cluster_info: Kubernetes cluster configuration. + :paramtype kubernetes_cluster_info: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesClusterInfo + :keyword kubernetes_role_resources: Kubernetes role resources. + :paramtype kubernetes_role_resources: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleResources + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "Kubernetes" self.host_platform = host_platform self.provisioning_state = None self.host_platform_type = None @@ -2569,46 +2765,45 @@ def __init__( self.role_status = role_status -class KubernetesRoleCompute(msrest.serialization.Model): +class KubernetesRoleCompute(_serialization.Model): """Kubernetes role compute resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param vm_profile: Required. VM profile. - :type vm_profile: str + :ivar vm_profile: VM profile. Required. + :vartype vm_profile: str :ivar memory_in_bytes: Memory in bytes. - :vartype memory_in_bytes: long + :vartype memory_in_bytes: int :ivar processor_count: Processor count. :vartype processor_count: int """ _validation = { - 'vm_profile': {'required': True}, - 'memory_in_bytes': {'readonly': True}, - 'processor_count': {'readonly': True}, + "vm_profile": {"required": True}, + "memory_in_bytes": {"readonly": True}, + "processor_count": {"readonly": True}, } _attribute_map = { - 'vm_profile': {'key': 'vmProfile', 'type': 'str'}, - 'memory_in_bytes': {'key': 'memoryInBytes', 'type': 'long'}, - 'processor_count': {'key': 'processorCount', 'type': 'int'}, + "vm_profile": {"key": "vmProfile", "type": "str"}, + "memory_in_bytes": {"key": "memoryInBytes", "type": "int"}, + "processor_count": {"key": "processorCount", "type": "int"}, } - def __init__( - self, - *, - vm_profile: str, - **kwargs - ): - super(KubernetesRoleCompute, self).__init__(**kwargs) + def __init__(self, *, vm_profile: str, **kwargs): + """ + :keyword vm_profile: VM profile. Required. + :paramtype vm_profile: str + """ + super().__init__(**kwargs) self.vm_profile = vm_profile self.memory_in_bytes = None self.processor_count = None -class KubernetesRoleNetwork(msrest.serialization.Model): +class KubernetesRoleNetwork(_serialization.Model): """Kubernetes role network resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2621,64 +2816,68 @@ class KubernetesRoleNetwork(msrest.serialization.Model): """ _validation = { - 'cni_config': {'readonly': True}, - 'load_balancer_config': {'readonly': True}, + "cni_config": {"readonly": True}, + "load_balancer_config": {"readonly": True}, } _attribute_map = { - 'cni_config': {'key': 'cniConfig', 'type': 'CniConfig'}, - 'load_balancer_config': {'key': 'loadBalancerConfig', 'type': 'LoadBalancerConfig'}, + "cni_config": {"key": "cniConfig", "type": "CniConfig"}, + "load_balancer_config": {"key": "loadBalancerConfig", "type": "LoadBalancerConfig"}, } - def __init__( - self, - **kwargs - ): - super(KubernetesRoleNetwork, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cni_config = None self.load_balancer_config = None -class KubernetesRoleResources(msrest.serialization.Model): +class KubernetesRoleResources(_serialization.Model): """Kubernetes role resources. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param storage: Kubernetes role storage resource. - :type storage: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleStorage - :param compute: Required. Kubernetes role compute resource. - :type compute: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleCompute + :ivar storage: Kubernetes role storage resource. + :vartype storage: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleStorage + :ivar compute: Kubernetes role compute resource. Required. + :vartype compute: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleCompute :ivar network: Kubernetes role network resource. :vartype network: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleNetwork """ _validation = { - 'compute': {'required': True}, - 'network': {'readonly': True}, + "compute": {"required": True}, + "network": {"readonly": True}, } _attribute_map = { - 'storage': {'key': 'storage', 'type': 'KubernetesRoleStorage'}, - 'compute': {'key': 'compute', 'type': 'KubernetesRoleCompute'}, - 'network': {'key': 'network', 'type': 'KubernetesRoleNetwork'}, + "storage": {"key": "storage", "type": "KubernetesRoleStorage"}, + "compute": {"key": "compute", "type": "KubernetesRoleCompute"}, + "network": {"key": "network", "type": "KubernetesRoleNetwork"}, } def __init__( self, *, - compute: "KubernetesRoleCompute", - storage: Optional["KubernetesRoleStorage"] = None, + compute: "_models.KubernetesRoleCompute", + storage: Optional["_models.KubernetesRoleStorage"] = None, **kwargs ): - super(KubernetesRoleResources, self).__init__(**kwargs) + """ + :keyword storage: Kubernetes role storage resource. + :paramtype storage: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleStorage + :keyword compute: Kubernetes role compute resource. Required. + :paramtype compute: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleCompute + """ + super().__init__(**kwargs) self.storage = storage self.compute = compute self.network = None -class KubernetesRoleStorage(msrest.serialization.Model): +class KubernetesRoleStorage(_serialization.Model): """Kubernetes role storage resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2686,31 +2885,30 @@ class KubernetesRoleStorage(msrest.serialization.Model): :ivar storage_classes: Kubernetes storage class info. :vartype storage_classes: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesRoleStorageClassInfo] - :param endpoints: Mount points of shares in role(s). - :type endpoints: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] + :ivar endpoints: Mount points of shares in role(s). + :vartype endpoints: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] """ _validation = { - 'storage_classes': {'readonly': True}, + "storage_classes": {"readonly": True}, } _attribute_map = { - 'storage_classes': {'key': 'storageClasses', 'type': '[KubernetesRoleStorageClassInfo]'}, - 'endpoints': {'key': 'endpoints', 'type': '[MountPointMap]'}, + "storage_classes": {"key": "storageClasses", "type": "[KubernetesRoleStorageClassInfo]"}, + "endpoints": {"key": "endpoints", "type": "[MountPointMap]"}, } - def __init__( - self, - *, - endpoints: Optional[List["MountPointMap"]] = None, - **kwargs - ): - super(KubernetesRoleStorage, self).__init__(**kwargs) + def __init__(self, *, endpoints: Optional[List["_models.MountPointMap"]] = None, **kwargs): + """ + :keyword endpoints: Mount points of shares in role(s). + :paramtype endpoints: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] + """ + super().__init__(**kwargs) self.storage_classes = None self.endpoints = endpoints -class KubernetesRoleStorageClassInfo(msrest.serialization.Model): +class KubernetesRoleStorageClassInfo(_serialization.Model): """Kubernetes storage class info. Variables are only populated by the server, and will be ignored when sending a request. @@ -2719,35 +2917,33 @@ class KubernetesRoleStorageClassInfo(msrest.serialization.Model): :vartype name: str :ivar type: Storage class type. :vartype type: str - :ivar posix_compliant: If provisioned storage is posix compliant. Possible values include: - "Invalid", "Enabled", "Disabled". + :ivar posix_compliant: If provisioned storage is posix compliant. Known values are: "Invalid", + "Enabled", and "Disabled". :vartype posix_compliant: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PosixComplianceStatus """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'posix_compliant': {'readonly': True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "posix_compliant": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'posix_compliant': {'key': 'posixCompliant', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "posix_compliant": {"key": "posixCompliant", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorageClassInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.type = None self.posix_compliant = None -class LoadBalancerConfig(msrest.serialization.Model): +class LoadBalancerConfig(_serialization.Model): """Load balancer configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2759,20 +2955,18 @@ class LoadBalancerConfig(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(LoadBalancerConfig, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None @@ -2790,119 +2984,139 @@ class MECRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param connection_string: Activation key of the MEC. - :type connection_string: + :ivar connection_string: Activation key of the MEC. + :vartype connection_string: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'AsymmetricEncryptedSecret'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "connection_string": {"key": "properties.connectionString", "type": "AsymmetricEncryptedSecret"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(MECRole, self).__init__(**kwargs) - self.kind = 'MEC' # type: str + """ + :keyword connection_string: Activation key of the MEC. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "MEC" self.connection_string = connection_string self.role_status = role_status -class MetricConfiguration(msrest.serialization.Model): +class MetricConfiguration(_serialization.Model): """Metric configuration. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. The Resource ID on which the metrics should be pushed. - :type resource_id: str - :param mdm_account: The MDM account to which the counters should be pushed. - :type mdm_account: str - :param metric_name_space: The MDM namespace to which the counters should be pushed. This is + :ivar resource_id: The Resource ID on which the metrics should be pushed. Required. + :vartype resource_id: str + :ivar mdm_account: The MDM account to which the counters should be pushed. + :vartype mdm_account: str + :ivar metric_name_space: The MDM namespace to which the counters should be pushed. This is required if MDMAccount is specified. - :type metric_name_space: str - :param counter_sets: Required. Host name for the IoT hub associated to the device. - :type counter_sets: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCounterSet] + :vartype metric_name_space: str + :ivar counter_sets: Host name for the IoT hub associated to the device. Required. + :vartype counter_sets: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCounterSet] """ _validation = { - 'resource_id': {'required': True}, - 'counter_sets': {'required': True}, + "resource_id": {"required": True}, + "counter_sets": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'mdm_account': {'key': 'mdmAccount', 'type': 'str'}, - 'metric_name_space': {'key': 'metricNameSpace', 'type': 'str'}, - 'counter_sets': {'key': 'counterSets', 'type': '[MetricCounterSet]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "mdm_account": {"key": "mdmAccount", "type": "str"}, + "metric_name_space": {"key": "metricNameSpace", "type": "str"}, + "counter_sets": {"key": "counterSets", "type": "[MetricCounterSet]"}, } def __init__( self, *, resource_id: str, - counter_sets: List["MetricCounterSet"], + counter_sets: List["_models.MetricCounterSet"], mdm_account: Optional[str] = None, metric_name_space: Optional[str] = None, **kwargs ): - super(MetricConfiguration, self).__init__(**kwargs) + """ + :keyword resource_id: The Resource ID on which the metrics should be pushed. Required. + :paramtype resource_id: str + :keyword mdm_account: The MDM account to which the counters should be pushed. + :paramtype mdm_account: str + :keyword metric_name_space: The MDM namespace to which the counters should be pushed. This is + required if MDMAccount is specified. + :paramtype metric_name_space: str + :keyword counter_sets: Host name for the IoT hub associated to the device. Required. + :paramtype counter_sets: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCounterSet] + """ + super().__init__(**kwargs) self.resource_id = resource_id self.mdm_account = mdm_account self.metric_name_space = metric_name_space self.counter_sets = counter_sets -class MetricCounter(msrest.serialization.Model): +class MetricCounter(_serialization.Model): """The metric counter. All required parameters must be populated in order to send to Azure. - :param name: Required. The counter name. - :type name: str - :param instance: The instance from which counter should be collected. - :type instance: str - :param dimension_filter: The dimension filter. - :type dimension_filter: + :ivar name: The counter name. Required. + :vartype name: str + :ivar instance: The instance from which counter should be collected. + :vartype instance: str + :ivar dimension_filter: The dimension filter. + :vartype dimension_filter: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimension] - :param additional_dimensions: The additional dimensions to be added to metric. - :type additional_dimensions: + :ivar additional_dimensions: The additional dimensions to be added to metric. + :vartype additional_dimensions: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimension] """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, - 'dimension_filter': {'key': 'dimensionFilter', 'type': '[MetricDimension]'}, - 'additional_dimensions': {'key': 'additionalDimensions', 'type': '[MetricDimension]'}, + "name": {"key": "name", "type": "str"}, + "instance": {"key": "instance", "type": "str"}, + "dimension_filter": {"key": "dimensionFilter", "type": "[MetricDimension]"}, + "additional_dimensions": {"key": "additionalDimensions", "type": "[MetricDimension]"}, } def __init__( @@ -2910,92 +3124,103 @@ def __init__( *, name: str, instance: Optional[str] = None, - dimension_filter: Optional[List["MetricDimension"]] = None, - additional_dimensions: Optional[List["MetricDimension"]] = None, + dimension_filter: Optional[List["_models.MetricDimension"]] = None, + additional_dimensions: Optional[List["_models.MetricDimension"]] = None, **kwargs ): - super(MetricCounter, self).__init__(**kwargs) + """ + :keyword name: The counter name. Required. + :paramtype name: str + :keyword instance: The instance from which counter should be collected. + :paramtype instance: str + :keyword dimension_filter: The dimension filter. + :paramtype dimension_filter: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimension] + :keyword additional_dimensions: The additional dimensions to be added to metric. + :paramtype additional_dimensions: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimension] + """ + super().__init__(**kwargs) self.name = name self.instance = instance self.dimension_filter = dimension_filter self.additional_dimensions = additional_dimensions -class MetricCounterSet(msrest.serialization.Model): +class MetricCounterSet(_serialization.Model): """The metric counter set. All required parameters must be populated in order to send to Azure. - :param counters: Required. The counters that should be collected in this set. - :type counters: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCounter] + :ivar counters: The counters that should be collected in this set. Required. + :vartype counters: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCounter] """ _validation = { - 'counters': {'required': True}, + "counters": {"required": True}, } _attribute_map = { - 'counters': {'key': 'counters', 'type': '[MetricCounter]'}, + "counters": {"key": "counters", "type": "[MetricCounter]"}, } - def __init__( - self, - *, - counters: List["MetricCounter"], - **kwargs - ): - super(MetricCounterSet, self).__init__(**kwargs) + def __init__(self, *, counters: List["_models.MetricCounter"], **kwargs): + """ + :keyword counters: The counters that should be collected in this set. Required. + :paramtype counters: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCounter] + """ + super().__init__(**kwargs) self.counters = counters -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """The metric dimension. All required parameters must be populated in order to send to Azure. - :param source_type: Required. The dimension type. - :type source_type: str - :param source_name: Required. The dimension value. - :type source_name: str + :ivar source_type: The dimension type. Required. + :vartype source_type: str + :ivar source_name: The dimension value. Required. + :vartype source_name: str """ _validation = { - 'source_type': {'required': True}, - 'source_name': {'required': True}, + "source_type": {"required": True}, + "source_name": {"required": True}, } _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'source_name': {'key': 'sourceName', 'type': 'str'}, - } - - def __init__( - self, - *, - source_type: str, - source_name: str, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) + "source_type": {"key": "sourceType", "type": "str"}, + "source_name": {"key": "sourceName", "type": "str"}, + } + + def __init__(self, *, source_type: str, source_name: str, **kwargs): + """ + :keyword source_type: The dimension type. Required. + :paramtype source_type: str + :keyword source_name: The dimension value. Required. + :paramtype source_name: str + """ + super().__init__(**kwargs) self.source_type = source_type self.source_name = source_name -class MetricDimensionV1(msrest.serialization.Model): +class MetricDimensionV1(_serialization.Model): """Metric Dimension v1. - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the metrics dimension. + :vartype name: str + :ivar display_name: Display name of the metrics dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -3006,56 +3231,64 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(MetricDimensionV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metrics dimension. + :paramtype name: str + :keyword display_name: Display name of the metrics dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecificationV1(msrest.serialization.Model): +class MetricSpecificationV1(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric specification version 1. - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Description of the metric to be displayed. + :vartype display_description: str + :ivar unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :vartype unit: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricUnit + :ivar aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :vartype aggregation_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or + :ivar dimensions: Metric dimensions, other than default dimension which is resource. + :vartype dimensions: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimensionV1] + :ivar fill_gap_with_zero: Set true to fill the gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar category: Metric category. Known values are: "Capacity" and "Transaction". + :vartype category: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCategory + :ivar resource_id_dimension_name_override: Resource name override. + :vartype resource_id_dimension_name_override: str + :ivar supported_time_grain_types: Support granularity of metrics. + :vartype supported_time_grain_types: list[str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricAggregationType] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimensionV1]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, } def __init__( @@ -3064,17 +3297,47 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, display_description: Optional[str] = None, - unit: Optional[Union[str, "MetricUnit"]] = None, - aggregation_type: Optional[Union[str, "MetricAggregationType"]] = None, - dimensions: Optional[List["MetricDimensionV1"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, + dimensions: Optional[List["_models.MetricDimensionV1"]] = None, fill_gap_with_zero: Optional[bool] = None, - category: Optional[Union[str, "MetricCategory"]] = None, + category: Optional[Union[str, "_models.MetricCategory"]] = None, resource_id_dimension_name_override: Optional[str] = None, - supported_time_grain_types: Optional[List[Union[str, "TimeGrain"]]] = None, - supported_aggregation_types: Optional[List[Union[str, "MetricAggregationType"]]] = None, + supported_time_grain_types: Optional[List[Union[str, "_models.TimeGrain"]]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, **kwargs ): - super(MetricSpecificationV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Description of the metric to be displayed. + :paramtype display_description: str + :keyword unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :paramtype unit: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricUnit + :keyword aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :paramtype aggregation_type: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricAggregationType + :keyword dimensions: Metric dimensions, other than default dimension which is resource. + :paramtype dimensions: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricDimensionV1] + :keyword fill_gap_with_zero: Set true to fill the gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: Metric category. Known values are: "Capacity" and "Transaction". + :paramtype category: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricCategory + :keyword resource_id_dimension_name_override: Resource name override. + :paramtype resource_id_dimension_name_override: str + :keyword supported_time_grain_types: Support granularity of metrics. + :paramtype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TimeGrain] + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricAggregationType] + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -3101,36 +3364,36 @@ class MonitoringMetricConfiguration(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param metric_configurations: Required. The metrics configuration details. - :type metric_configurations: + :ivar metric_configurations: The metrics configuration details. Required. + :vartype metric_configurations: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricConfiguration] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'metric_configurations': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "metric_configurations": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metric_configurations': {'key': 'properties.metricConfigurations', 'type': '[MetricConfiguration]'}, - } - - def __init__( - self, - *, - metric_configurations: List["MetricConfiguration"], - **kwargs - ): - super(MonitoringMetricConfiguration, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metric_configurations": {"key": "properties.metricConfigurations", "type": "[MetricConfiguration]"}, + } + + def __init__(self, *, metric_configurations: List["_models.MetricConfiguration"], **kwargs): + """ + :keyword metric_configurations: The metrics configuration details. Required. + :paramtype metric_configurations: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricConfiguration] + """ + super().__init__(**kwargs) self.metric_configurations = metric_configurations -class MonitoringMetricConfigurationList(msrest.serialization.Model): +class MonitoringMetricConfigurationList(_serialization.Model): """Collection of metric configurations. Variables are only populated by the server, and will be ignored when sending a request. @@ -3143,67 +3406,64 @@ class MonitoringMetricConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MonitoringMetricConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MonitoringMetricConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class MountPointMap(msrest.serialization.Model): +class MountPointMap(_serialization.Model): """The share mount point. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str + :ivar share_id: ID of the share mounted to the role VM. Required. + :vartype share_id: str :ivar role_id: ID of the role to which share is mounted. :vartype role_id: str :ivar mount_point: Mount point for the share. :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". + :ivar mount_type: Mounting type. Known values are: "Volume" and "HostPath". :vartype mount_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive", - "MEC", "CloudEdgeManagement", "Kubernetes". + :ivar role_type: Role type. Known values are: "IOT", "ASA", "Functions", "Cognitive", "MEC", + "CloudEdgeManagement", and "Kubernetes". :vartype role_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleTypes """ _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, + "share_id": {"required": True}, + "role_id": {"readonly": True}, + "mount_point": {"readonly": True}, + "mount_type": {"readonly": True}, + "role_type": {"readonly": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "mount_point": {"key": "mountPoint", "type": "str"}, + "mount_type": {"key": "mountType", "type": "str"}, + "role_type": {"key": "roleType", "type": "str"}, + } + + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: ID of the share mounted to the role VM. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id self.role_id = None self.mount_point = None @@ -3211,7 +3471,7 @@ def __init__( self.role_type = None -class NetworkAdapter(msrest.serialization.Model): +class NetworkAdapter(_serialization.Model): # pylint: disable=too-many-instance-attributes """Represents the networkAdapter on a device. Variables are only populated by the server, and will be ignored when sending a request. @@ -3232,17 +3492,17 @@ class NetworkAdapter(msrest.serialization.Model): :ivar mac_address: MAC address. :vartype mac_address: str :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". + :vartype link_speed: int + :ivar status: Value indicating whether this adapter is valid. Known values are: "Inactive" and + "Active". :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or + :ivar rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :vartype rdma_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or + :ivar dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :vartype dhcp_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapterDHCPStatus :ivar ipv4_configuration: The IPv4 configuration of the network adapter. :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Ipv4Config @@ -3255,47 +3515,57 @@ class NetworkAdapter(msrest.serialization.Model): """ _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, + "adapter_id": {"readonly": True}, + "adapter_position": {"readonly": True}, + "index": {"readonly": True}, + "node_id": {"readonly": True}, + "network_adapter_name": {"readonly": True}, + "label": {"readonly": True}, + "mac_address": {"readonly": True}, + "link_speed": {"readonly": True}, + "status": {"readonly": True}, + "ipv4_configuration": {"readonly": True}, + "ipv6_configuration": {"readonly": True}, + "ipv6_link_local_address": {"readonly": True}, + "dns_servers": {"readonly": True}, } _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, + "adapter_id": {"key": "adapterId", "type": "str"}, + "adapter_position": {"key": "adapterPosition", "type": "NetworkAdapterPosition"}, + "index": {"key": "index", "type": "int"}, + "node_id": {"key": "nodeId", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "mac_address": {"key": "macAddress", "type": "str"}, + "link_speed": {"key": "linkSpeed", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "rdma_status": {"key": "rdmaStatus", "type": "str"}, + "dhcp_status": {"key": "dhcpStatus", "type": "str"}, + "ipv4_configuration": {"key": "ipv4Configuration", "type": "Ipv4Config"}, + "ipv6_configuration": {"key": "ipv6Configuration", "type": "Ipv6Config"}, + "ipv6_link_local_address": {"key": "ipv6LinkLocalAddress", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, } def __init__( self, *, - rdma_status: Optional[Union[str, "NetworkAdapterRDMAStatus"]] = None, - dhcp_status: Optional[Union[str, "NetworkAdapterDHCPStatus"]] = None, + rdma_status: Optional[Union[str, "_models.NetworkAdapterRDMAStatus"]] = None, + dhcp_status: Optional[Union[str, "_models.NetworkAdapterDHCPStatus"]] = None, **kwargs ): - super(NetworkAdapter, self).__init__(**kwargs) + """ + :keyword rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :paramtype rdma_status: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapterRDMAStatus + :keyword dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :paramtype dhcp_status: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkAdapterDHCPStatus + """ + super().__init__(**kwargs) self.adapter_id = None self.adapter_position = None self.index = None @@ -3313,32 +3583,30 @@ def __init__( self.dns_servers = None -class NetworkAdapterPosition(msrest.serialization.Model): +class NetworkAdapterPosition(_serialization.Model): """The network adapter position. Variables are only populated by the server, and will be ignored when sending a request. - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". + :ivar network_group: The network group. Known values are: "None", "NonRDMA", and "RDMA". :vartype network_group: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkGroup :ivar port: The port. :vartype port: int """ _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, + "network_group": {"readonly": True}, + "port": {"readonly": True}, } _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, + "network_group": {"key": "networkGroup", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_group = None self.port = None @@ -3360,89 +3628,85 @@ class NetworkSettings(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'network_adapters': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "network_adapters": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "network_adapters": {"key": "properties.networkAdapters", "type": "[NetworkAdapter]"}, } - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_adapters = None class Node(ARMBaseModel): """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str + Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node + Multi-node Edge devices will have more than 1 nodes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar node_status: The current status of the individual node. Known values are: "Unknown", + "Up", "Down", "Rebooting", and "ShuttingDown". + :vartype node_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NodeStatus + :ivar node_chassis_serial_number: Serial number of the Chassis. + :vartype node_chassis_serial_number: str + :ivar node_serial_number: Serial number of the individual node. + :vartype node_serial_number: str + :ivar node_display_name: Display Name of the individual node. + :vartype node_display_name: str + :ivar node_friendly_software_version: Friendly software version name that is currently + installed on the node. + :vartype node_friendly_software_version: str + :ivar node_hcs_version: HCS version that is currently installed on the node. + :vartype node_hcs_version: str + :ivar node_instance_id: Guid instance id of the node. + :vartype node_instance_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "node_status": {"readonly": True}, + "node_chassis_serial_number": {"readonly": True}, + "node_serial_number": {"readonly": True}, + "node_display_name": {"readonly": True}, + "node_friendly_software_version": {"readonly": True}, + "node_hcs_version": {"readonly": True}, + "node_instance_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "node_status": {"key": "properties.nodeStatus", "type": "str"}, + "node_chassis_serial_number": {"key": "properties.nodeChassisSerialNumber", "type": "str"}, + "node_serial_number": {"key": "properties.nodeSerialNumber", "type": "str"}, + "node_display_name": {"key": "properties.nodeDisplayName", "type": "str"}, + "node_friendly_software_version": {"key": "properties.nodeFriendlySoftwareVersion", "type": "str"}, + "node_hcs_version": {"key": "properties.nodeHcsVersion", "type": "str"}, + "node_instance_id": {"key": "properties.nodeInstanceId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.node_status = None self.node_chassis_serial_number = None self.node_serial_number = None @@ -3452,109 +3716,121 @@ def __init__( self.node_instance_id = None -class NodeInfo(msrest.serialization.Model): +class NodeInfo(_serialization.Model): """Kubernetes node info. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: Node name. :vartype name: str - :ivar type: Node type - Master/Worker. Possible values include: "Invalid", "Master", "Worker". + :ivar type: Node type - Master/Worker. Known values are: "Invalid", "Master", and "Worker". :vartype type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesNodeType - :param ip_configuration: IP Configuration of the Kubernetes node. - :type ip_configuration: + :ivar ip_configuration: IP Configuration of the Kubernetes node. + :vartype ip_configuration: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesIPConfiguration] """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_configuration': {'key': 'ipConfiguration', 'type': '[KubernetesIPConfiguration]'}, - } - - def __init__( - self, - *, - ip_configuration: Optional[List["KubernetesIPConfiguration"]] = None, - **kwargs - ): - super(NodeInfo, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "ip_configuration": {"key": "ipConfiguration", "type": "[KubernetesIPConfiguration]"}, + } + + def __init__(self, *, ip_configuration: Optional[List["_models.KubernetesIPConfiguration"]] = None, **kwargs): + """ + :keyword ip_configuration: IP Configuration of the Kubernetes node. + :paramtype ip_configuration: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.KubernetesIPConfiguration] + """ + super().__init__(**kwargs) self.name = None self.type = None self.ip_configuration = ip_configuration -class NodeList(msrest.serialization.Model): +class NodeList(_serialization.Model): """Collection of Nodes. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of Nodes. :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Node] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Node]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: Optional[str] = None, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) + def __init__(self, *, next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = None self.next_link = next_link -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operations. - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param service_specification: Service specification. - :type service_specification: + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties displayed for the operation. + :vartype display: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar service_specification: Service specification. + :vartype service_specification: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ServiceSpecification """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, is_data_action: Optional[bool] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): - super(Operation, self).__init__(**kwargs) + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties displayed for the operation. + :paramtype display: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword service_specification: Service specification. + :paramtype service_specification: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ServiceSpecification + """ + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin @@ -3562,24 +3838,24 @@ def __init__( self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display properties. - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: The type of resource in which the operation is performed. + :vartype resource: str + :ivar operation: Operation to be performed on the resource. + :vartype operation: str + :ivar description: Description of the operation to be performed. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -3591,46 +3867,56 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: The type of resource in which the operation is performed. + :paramtype resource: str + :keyword operation: Operation to be performed on the resource. + :paramtype operation: str + :keyword description: Description of the operation to be performed. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsList(msrest.serialization.Model): +class OperationsList(_serialization.Model): """The list of operations used for the discovery of available provider operations. All required parameters must be populated in order to send to Azure. - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar value: The value. Required. + :vartype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Operation] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: List["Operation"], - next_link: Optional[str] = None, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The value. Required. + :paramtype value: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Operation] + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Order(ARMBaseModel): +class Order(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The order details. Variables are only populated by the server, and will be ignored when sending a request. @@ -3641,10 +3927,10 @@ class Order(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Address + :ivar contact_information: The contact details. + :vartype contact_information: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ContactDetails + :ivar shipping_address: The shipping address. + :vartype shipping_address: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Address :ivar current_status: Current status of the order. :vartype current_status: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OrderStatus :ivar order_history: List of status changes in the order. @@ -3659,45 +3945,56 @@ class Order(ARMBaseModel): whether it has an original or a replacement device. :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.TrackingInfo] - :param shipment_type: ShipmentType of the order. Possible values include: "NotApplicable", - "ShippedToCustomer", "SelfPickup". - :type shipment_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShipmentType + :ivar shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :vartype shipment_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShipmentType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'current_status': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "current_status": {"readonly": True}, + "order_history": {"readonly": True}, + "serial_number": {"readonly": True}, + "delivery_tracking_info": {"readonly": True}, + "return_tracking_info": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - 'shipment_type': {'key': 'properties.shipmentType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "contact_information": {"key": "properties.contactInformation", "type": "ContactDetails"}, + "shipping_address": {"key": "properties.shippingAddress", "type": "Address"}, + "current_status": {"key": "properties.currentStatus", "type": "OrderStatus"}, + "order_history": {"key": "properties.orderHistory", "type": "[OrderStatus]"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "delivery_tracking_info": {"key": "properties.deliveryTrackingInfo", "type": "[TrackingInfo]"}, + "return_tracking_info": {"key": "properties.returnTrackingInfo", "type": "[TrackingInfo]"}, + "shipment_type": {"key": "properties.shipmentType", "type": "str"}, } def __init__( self, *, - contact_information: Optional["ContactDetails"] = None, - shipping_address: Optional["Address"] = None, - shipment_type: Optional[Union[str, "ShipmentType"]] = None, + contact_information: Optional["_models.ContactDetails"] = None, + shipping_address: Optional["_models.Address"] = None, + shipment_type: Optional[Union[str, "_models.ShipmentType"]] = None, **kwargs ): - super(Order, self).__init__(**kwargs) + """ + :keyword contact_information: The contact details. + :paramtype contact_information: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ContactDetails + :keyword shipping_address: The shipping address. + :paramtype shipping_address: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Address + :keyword shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :paramtype shipment_type: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShipmentType + """ + super().__init__(**kwargs) self.contact_information = contact_information self.shipping_address = shipping_address self.current_status = None @@ -3708,7 +4005,7 @@ def __init__( self.shipment_type = shipment_type -class OrderList(msrest.serialization.Model): +class OrderList(_serialization.Model): """List of order entities. Variables are only populated by the server, and will be ignored when sending a request. @@ -3720,41 +4017,39 @@ class OrderList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Order]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OrderStatus(msrest.serialization.Model): +class OrderStatus(_serialization.Model): """Represents a single status change. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", - "AwaitingPickup", "PickupCompleted", "AwaitingDrop". - :type status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OrderState + :ivar status: Status of the order as per the allowed status types. Required. Known values are: + "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :vartype status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OrderState :ivar update_date_time: Time of status update. :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str + :ivar comments: Comments related to this status change. + :vartype comments: str :ivar tracking_information: Tracking information related to the state in the ordering flow. :vartype tracking_information: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TrackingInfo :ivar additional_order_details: Dictionary to hold generic information which is not stored @@ -3763,28 +4058,32 @@ class OrderStatus(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'tracking_information': {'readonly': True}, - 'additional_order_details': {'readonly': True}, + "status": {"required": True}, + "update_date_time": {"readonly": True}, + "tracking_information": {"readonly": True}, + "additional_order_details": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'tracking_information': {'key': 'trackingInformation', 'type': 'TrackingInfo'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - *, - status: Union[str, "OrderState"], - comments: Optional[str] = None, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) + "status": {"key": "status", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + "comments": {"key": "comments", "type": "str"}, + "tracking_information": {"key": "trackingInformation", "type": "TrackingInfo"}, + "additional_order_details": {"key": "additionalOrderDetails", "type": "{str}"}, + } + + def __init__(self, *, status: Union[str, "_models.OrderState"], comments: Optional[str] = None, **kwargs): + """ + :keyword status: Status of the order as per the allowed status types. Required. Known values + are: "Untracked", "AwaitingFulfilment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :paramtype status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.OrderState + :keyword comments: Comments related to this status change. + :paramtype comments: str + """ + super().__init__(**kwargs) self.status = status self.update_date_time = None self.comments = comments @@ -3807,122 +4106,137 @@ class PeriodicTimerEventTrigger(Trigger): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerEventType + :ivar source_info: Periodic timer details. Required. + :vartype source_info: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PeriodicTimerSourceInfo + :ivar sink_info: Role Sink information. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "PeriodicTimerSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "PeriodicTimerSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.PeriodicTimerSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str + """ + :keyword source_info: Periodic timer details. Required. + :paramtype source_info: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.PeriodicTimerSourceInfo + :keyword sink_info: Role Sink information. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "PeriodicTimerEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class PeriodicTimerSourceInfo(msrest.serialization.Model): +class PeriodicTimerSourceInfo(_serialization.Model): """Periodic timer event source. All required parameters must be populated in order to send to Azure. - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str + :ivar start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :vartype start_time: ~datetime.datetime + :ivar schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :vartype schedule: str + :ivar topic: Topic where periodic events are published to IoT device. + :vartype topic: str """ _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, + "start_time": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - *, - start_time: datetime.datetime, - schedule: str, - topic: Optional[str] = None, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) + "start_time": {"key": "startTime", "type": "iso-8601"}, + "schedule": {"key": "schedule", "type": "str"}, + "topic": {"key": "topic", "type": "str"}, + } + + def __init__(self, *, start_time: datetime.datetime, schedule: str, topic: Optional[str] = None, **kwargs): + """ + :keyword start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :paramtype start_time: ~datetime.datetime + :keyword schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :paramtype schedule: str + :keyword topic: Topic where periodic events are published to IoT device. + :paramtype topic: str + """ + super().__init__(**kwargs) self.start_time = start_time self.schedule = schedule self.topic = topic -class RefreshDetails(msrest.serialization.Model): +class RefreshDetails(_serialization.Model): """Fields for tracking refresh job on the share or container. - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + :ivar in_progress_refresh_job_id: If a refresh job is currently in progress on this share or container, this field indicates the ARM resource ID of that job. The field is empty if no job is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh + :vartype in_progress_refresh_job_id: str + :ivar last_completed_refresh_job_time_in_utc: Indicates the completed time for the last refresh + job on this particular share or container, if any.This could be a failed job or a successful + job. + :vartype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :ivar error_manifest_file: Indicates the relative path of the error xml for the last refresh job on this particular share or container, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or + :vartype error_manifest_file: str + :ivar last_job: Indicates the id of the last refresh job on this particular share or container,if any. This could be a failed job or a successful job. - :type last_job: str + :vartype last_job: str """ _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, + "in_progress_refresh_job_id": {"key": "inProgressRefreshJobId", "type": "str"}, + "last_completed_refresh_job_time_in_utc": {"key": "lastCompletedRefreshJobTimeInUTC", "type": "iso-8601"}, + "error_manifest_file": {"key": "errorManifestFile", "type": "str"}, + "last_job": {"key": "lastJob", "type": "str"}, } def __init__( @@ -3934,20 +4248,37 @@ def __init__( last_job: Optional[str] = None, **kwargs ): - super(RefreshDetails, self).__init__(**kwargs) + """ + :keyword in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + container, this field indicates the ARM resource ID of that job. The field is empty if no job + is in progress. + :paramtype in_progress_refresh_job_id: str + :keyword last_completed_refresh_job_time_in_utc: Indicates the completed time for the last + refresh job on this particular share or container, if any.This could be a failed job or a + successful job. + :paramtype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :keyword error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share or container, if any. This could be a failed job or a successful + job. + :paramtype error_manifest_file: str + :keyword last_job: Indicates the id of the last refresh job on this particular share or + container,if any. This could be a failed job or a successful job. + :paramtype last_job: str + """ + super().__init__(**kwargs) self.in_progress_refresh_job_id = in_progress_refresh_job_id self.last_completed_refresh_job_time_in_utc = last_completed_refresh_job_time_in_utc self.error_manifest_file = error_manifest_file self.last_job = last_job -class ResourceIdentity(msrest.serialization.Model): +class ResourceIdentity(_serialization.Model): """Msi identity details of the resource. Variables are only populated by the server, and will be ignored when sending a request. - :param type: Identity type. Possible values include: "None", "SystemAssigned", "UserAssigned". - :type type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MsiIdentityType + :ivar type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :vartype type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MsiIdentityType :ivar principal_id: Service Principal Id backing the Msi. :vartype principal_id: str :ivar tenant_id: Home Tenant Id. @@ -3955,58 +4286,66 @@ class ResourceIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "MsiIdentityType"]] = None, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) + def __init__(self, *, type: Optional[Union[str, "_models.MsiIdentityType"]] = None, **kwargs): + """ + :keyword type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :paramtype type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MsiIdentityType + """ + super().__init__(**kwargs) self.type = type self.principal_id = None self.tenant_id = None -class ResourceMoveDetails(msrest.serialization.Model): +class ResourceMoveDetails(_serialization.Model): """Fields for tracking resource move. - :param operation_in_progress: Denotes whether move operation is in progress. Possible values - include: "None", "ResourceMoveInProgress", "ResourceMoveFailed". - :type operation_in_progress: str or + :ivar operation_in_progress: Denotes whether move operation is in progress. Known values are: + "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :vartype operation_in_progress: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceMoveStatus - :param operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + :ivar operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to finish. - :type operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + :vartype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime """ _attribute_map = { - 'operation_in_progress': {'key': 'operationInProgress', 'type': 'str'}, - 'operation_in_progress_lock_timeout_in_utc': {'key': 'operationInProgressLockTimeoutInUTC', 'type': 'iso-8601'}, + "operation_in_progress": {"key": "operationInProgress", "type": "str"}, + "operation_in_progress_lock_timeout_in_utc": {"key": "operationInProgressLockTimeoutInUTC", "type": "iso-8601"}, } def __init__( self, *, - operation_in_progress: Optional[Union[str, "ResourceMoveStatus"]] = None, + operation_in_progress: Optional[Union[str, "_models.ResourceMoveStatus"]] = None, operation_in_progress_lock_timeout_in_utc: Optional[datetime.datetime] = None, **kwargs ): - super(ResourceMoveDetails, self).__init__(**kwargs) + """ + :keyword operation_in_progress: Denotes whether move operation is in progress. Known values + are: "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :paramtype operation_in_progress: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ResourceMoveStatus + :keyword operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + finish. + :paramtype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + """ + super().__init__(**kwargs) self.operation_in_progress = operation_in_progress self.operation_in_progress_lock_timeout_in_utc = operation_in_progress_lock_timeout_in_utc -class ResourceTypeSku(msrest.serialization.Model): +class ResourceTypeSku(_serialization.Model): """Resource type Sku object. Variables are only populated by the server, and will be ignored when sending a request. @@ -4018,25 +4357,23 @@ class ResourceTypeSku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'skus': {'readonly': True}, + "resource_type": {"readonly": True}, + "skus": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'skus': {'key': 'skus', 'type': '[SkuInformation]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "skus": {"key": "skus", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.skus = None -class RoleList(msrest.serialization.Model): +class RoleList(_serialization.Model): """Collection of all the roles on the Data Box Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4048,48 +4385,45 @@ class RoleList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Role]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RoleSinkInfo(msrest.serialization.Model): +class RoleSinkInfo(_serialization.Model): """Compute role against which events will be raised. All required parameters must be populated in order to send to Azure. - :param role_id: Required. Compute role ID. - :type role_id: str + :ivar role_id: Compute role ID. Required. + :vartype role_id: str """ _validation = { - 'role_id': {'required': True}, + "role_id": {"required": True}, } _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, + "role_id": {"key": "roleId", "type": "str"}, } - def __init__( - self, - *, - role_id: str, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) + def __init__(self, *, role_id: str, **kwargs): + """ + :keyword role_id: Compute role ID. Required. + :paramtype role_id: str + """ + super().__init__(**kwargs) self.role_id = role_id @@ -4106,61 +4440,64 @@ class SecuritySettings(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: + :ivar device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :vartype device_admin_password: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "device_admin_password": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - *, - device_admin_password: "AsymmetricEncryptedSecret", - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_admin_password": {"key": "properties.deviceAdminPassword", "type": "AsymmetricEncryptedSecret"}, + } + + def __init__(self, *, device_admin_password: "_models.AsymmetricEncryptedSecret", **kwargs): + """ + :keyword device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :paramtype device_admin_password: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.device_admin_password = device_admin_password -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification. - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: + :ivar metric_specifications: Metric specification as defined by shoebox. + :vartype metric_specifications: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricSpecificationV1] """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecificationV1]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["MetricSpecificationV1"]] = None, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecificationV1"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specification as defined by shoebox. + :paramtype metric_specifications: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MetricSpecificationV1] + """ + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Share(ARMBaseModel): +class Share(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Represents a share on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4175,81 +4512,111 @@ class Share(ARMBaseModel): :vartype type: str :ivar system_data: Share on ASE device. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or + :ivar description: Description for the share. + :vartype description: str + :ivar share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :vartype share_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareStatus + :ivar monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :vartype monitoring_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: + :ivar azure_container_info: Azure container mapping for the share. + :vartype azure_container_info: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or + :ivar access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :vartype access_protocol: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share + :ivar user_access_rights: Mapping of users and corresponding access rights on the share (required for SMB protocol). - :type user_access_rights: + :vartype user_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the + :ivar client_access_rights: List of IP addresses and corresponding access rights on the share(required for NFS protocol). - :type client_access_rights: + :vartype client_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RefreshDetails + :ivar refresh_details: Details of the refresh job on this share. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RefreshDetails :ivar share_mappings: Share mount point to the role. :vartype share_mappings: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataPolicy + :ivar data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_status": {"required": True}, + "monitoring_status": {"required": True}, + "access_protocol": {"required": True}, + "share_mappings": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "share_status": {"key": "properties.shareStatus", "type": "str"}, + "monitoring_status": {"key": "properties.monitoringStatus", "type": "str"}, + "azure_container_info": {"key": "properties.azureContainerInfo", "type": "AzureContainerInfo"}, + "access_protocol": {"key": "properties.accessProtocol", "type": "str"}, + "user_access_rights": {"key": "properties.userAccessRights", "type": "[UserAccessRight]"}, + "client_access_rights": {"key": "properties.clientAccessRights", "type": "[ClientAccessRight]"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, } def __init__( self, *, - share_status: Union[str, "ShareStatus"], - monitoring_status: Union[str, "MonitoringStatus"], - access_protocol: Union[str, "ShareAccessProtocol"], + share_status: Union[str, "_models.ShareStatus"], + monitoring_status: Union[str, "_models.MonitoringStatus"], + access_protocol: Union[str, "_models.ShareAccessProtocol"], description: Optional[str] = None, - azure_container_info: Optional["AzureContainerInfo"] = None, - user_access_rights: Optional[List["UserAccessRight"]] = None, - client_access_rights: Optional[List["ClientAccessRight"]] = None, - refresh_details: Optional["RefreshDetails"] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, + azure_container_info: Optional["_models.AzureContainerInfo"] = None, + user_access_rights: Optional[List["_models.UserAccessRight"]] = None, + client_access_rights: Optional[List["_models.ClientAccessRight"]] = None, + refresh_details: Optional["_models.RefreshDetails"] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, **kwargs ): - super(Share, self).__init__(**kwargs) + """ + :keyword description: Description for the share. + :paramtype description: str + :keyword share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :paramtype share_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareStatus + :keyword monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :paramtype monitoring_status: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringStatus + :keyword azure_container_info: Azure container mapping for the share. + :paramtype azure_container_info: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AzureContainerInfo + :keyword access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :paramtype access_protocol: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessProtocol + :keyword user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :paramtype user_access_rights: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.UserAccessRight] + :keyword client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :paramtype client_access_rights: + list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ClientAccessRight] + :keyword refresh_details: Details of the refresh job on this share. + :paramtype refresh_details: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.RefreshDetails + :keyword data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataPolicy + """ + super().__init__(**kwargs) self.system_data = None self.description = description self.share_status = share_status @@ -4263,41 +4630,43 @@ def __init__( self.data_policy = data_policy -class ShareAccessRight(msrest.serialization.Model): +class ShareAccessRight(_serialization.Model): """Specifies the mapping between this particular user and the type of access he has on shares on this device. All required parameters must be populated in order to send to Azure. - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessType + :ivar share_id: The share ID. Required. + :vartype share_id: str + :ivar access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessType """ _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, + "share_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, share_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword share_id: The share ID. Required. + :paramtype share_id: str + :keyword access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :paramtype access_type: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessType + """ + super().__init__(**kwargs) self.share_id = share_id self.access_type = access_type -class ShareList(msrest.serialization.Model): +class ShareList(_serialization.Model): """Collection of all the shares on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4309,54 +4678,61 @@ class ShareList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Share]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU type. - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC". - :type name: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuTier + :ivar name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", and "RDC". + :vartype name: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuTier """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "SkuName"]] = None, - tier: Optional[Union[str, "SkuTier"]] = None, + name: Optional[Union[str, "_models.SkuName"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, **kwargs ): - super(Sku, self).__init__(**kwargs) + """ + :keyword name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EdgeMR_Mini", "RCA_Small", "RCA_Large", and "RDC". + :paramtype name: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuName + :keyword tier: The SKU tier. This is based on the SKU name. "Standard" + :paramtype tier: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SkuTier + """ + super().__init__(**kwargs) self.name = name self.tier = tier -class SkuCost(msrest.serialization.Model): +class SkuCost(_serialization.Model): """The metadata for retrieving price info. Variables are only populated by the server, and will be ignored when sending a request. @@ -4364,34 +4740,32 @@ class SkuCost(msrest.serialization.Model): :ivar meter_id: Used for querying price from commerce. :vartype meter_id: str :ivar quantity: The cost quantity. - :vartype quantity: long + :vartype quantity: int :ivar extended_unit: The extended unit. :vartype extended_unit: str """ _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, + "meter_id": {"readonly": True}, + "quantity": {"readonly": True}, + "extended_unit": {"readonly": True}, } _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, + "meter_id": {"key": "meterId", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.meter_id = None self.quantity = None self.extended_unit = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Sku information. Variables are only populated by the server, and will be ignored when sending a request. @@ -4418,34 +4792,32 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'family': {'readonly': True}, - 'costs': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, + "name": {"readonly": True}, + "tier": {"readonly": True}, + "kind": {"readonly": True}, + "family": {"readonly": True}, + "costs": {"readonly": True}, + "locations": {"readonly": True}, + "location_info": {"readonly": True}, + "required_quota_ids": {"readonly": True}, + "required_features": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "required_quota_ids": {"key": "requiredQuotaIds", "type": "[str]"}, + "required_features": {"key": "requiredFeatures", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.tier = None self.kind = None @@ -4457,7 +4829,7 @@ def __init__( self.required_features = None -class SkuInformationList(msrest.serialization.Model): +class SkuInformationList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -4469,25 +4841,23 @@ class SkuInformationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceTypeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SkuLocationInfo(msrest.serialization.Model): +class SkuLocationInfo(_serialization.Model): """The location info. Variables are only populated by the server, and will be ignored when sending a request. @@ -4501,22 +4871,20 @@ class SkuLocationInfo(msrest.serialization.Model): """ _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, + "location": {"readonly": True}, + "zones": {"readonly": True}, + "sites": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "sites": {"key": "sites", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.zones = None self.sites = None @@ -4537,17 +4905,17 @@ class StorageAccount(ARMBaseModel): :vartype type: str :ivar system_data: StorageAccount object on ASE device. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or + :ivar description: Description for the storage Account. + :vartype description: str + :ivar storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :vartype storage_account_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountStatus - :param data_policy: Required. Data policy of the storage Account. Possible values include: - "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str + :ivar data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" and + "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataPolicy + :ivar storage_account_credential_id: Storage Account Credential Id. + :vartype storage_account_credential_id: str :ivar blob_endpoint: BlobEndpoint of Storage Account. :vartype blob_endpoint: str :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy @@ -4556,38 +4924,51 @@ class StorageAccount(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'data_policy': {'required': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "data_policy": {"required": True}, + "blob_endpoint": {"readonly": True}, + "container_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "storage_account_status": {"key": "properties.storageAccountStatus", "type": "str"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, + "storage_account_credential_id": {"key": "properties.storageAccountCredentialId", "type": "str"}, + "blob_endpoint": {"key": "properties.blobEndpoint", "type": "str"}, + "container_count": {"key": "properties.containerCount", "type": "int"}, } def __init__( self, *, - data_policy: Union[str, "DataPolicy"], + data_policy: Union[str, "_models.DataPolicy"], description: Optional[str] = None, - storage_account_status: Optional[Union[str, "StorageAccountStatus"]] = None, + storage_account_status: Optional[Union[str, "_models.StorageAccountStatus"]] = None, storage_account_credential_id: Optional[str] = None, **kwargs ): - super(StorageAccount, self).__init__(**kwargs) + """ + :keyword description: Description for the storage Account. + :paramtype description: str + :keyword storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :paramtype storage_account_status: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountStatus + :keyword data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" + and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataPolicy + :keyword storage_account_credential_id: Storage Account Credential Id. + :paramtype storage_account_credential_id: str + """ + super().__init__(**kwargs) self.system_data = None self.description = description self.storage_account_status = storage_account_status @@ -4597,7 +4978,7 @@ def __init__( self.container_count = None -class StorageAccountCredential(ARMBaseModel): +class StorageAccountCredential(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The storage account credential. Variables are only populated by the server, and will be ignored when sending a request. @@ -4612,66 +4993,89 @@ class StorageAccountCredential(ARMBaseModel): :vartype type: str :ivar system_data: StorageAccountCredential object. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str + :ivar alias: Alias for the storage account. Required. + :vartype alias: str + :ivar user_name: Username for the storage account. + :vartype user_name: str + :ivar account_key: Encrypted storage key. + :vartype account_key: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string for the storage account. Use this string if username + and account key are not specified. + :vartype connection_string: str + :ivar ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values are: + "Enabled" and "Disabled". + :vartype ssl_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SSLStatus + :ivar blob_domain_name: Blob end point for private clouds. + :vartype blob_domain_name: str + :ivar account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :vartype account_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AccountType + :ivar storage_account_id: Id of the storage account. + :vartype storage_account_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "alias": {"required": True}, + "ssl_status": {"required": True}, + "account_type": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "alias": {"key": "properties.alias", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "account_key": {"key": "properties.accountKey", "type": "AsymmetricEncryptedSecret"}, + "connection_string": {"key": "properties.connectionString", "type": "str"}, + "ssl_status": {"key": "properties.sslStatus", "type": "str"}, + "blob_domain_name": {"key": "properties.blobDomainName", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, } def __init__( self, *, alias: str, - ssl_status: Union[str, "SSLStatus"], - account_type: Union[str, "AccountType"], + ssl_status: Union[str, "_models.SSLStatus"], + account_type: Union[str, "_models.AccountType"], user_name: Optional[str] = None, - account_key: Optional["AsymmetricEncryptedSecret"] = None, + account_key: Optional["_models.AsymmetricEncryptedSecret"] = None, connection_string: Optional[str] = None, blob_domain_name: Optional[str] = None, storage_account_id: Optional[str] = None, **kwargs ): - super(StorageAccountCredential, self).__init__(**kwargs) + """ + :keyword alias: Alias for the storage account. Required. + :paramtype alias: str + :keyword user_name: Username for the storage account. + :paramtype user_name: str + :keyword account_key: Encrypted storage key. + :paramtype account_key: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret + :keyword connection_string: Connection string for the storage account. Use this string if + username and account key are not specified. + :paramtype connection_string: str + :keyword ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values + are: "Enabled" and "Disabled". + :paramtype ssl_status: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SSLStatus + :keyword blob_domain_name: Blob end point for private clouds. + :paramtype blob_domain_name: str + :keyword account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :paramtype account_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AccountType + :keyword storage_account_id: Id of the storage account. + :paramtype storage_account_id: str + """ + super().__init__(**kwargs) self.system_data = None self.alias = alias self.user_name = user_name @@ -4683,7 +5087,7 @@ def __init__( self.storage_account_id = storage_account_id -class StorageAccountCredentialList(msrest.serialization.Model): +class StorageAccountCredentialList(_serialization.Model): """The collection of storage account credentials. Variables are only populated by the server, and will be ignored when sending a request. @@ -4696,25 +5100,23 @@ class StorageAccountCredentialList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccountCredential]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountList(msrest.serialization.Model): +class StorageAccountList(_serialization.Model): """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4726,113 +5128,130 @@ class StorageAccountList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SubscriptionRegisteredFeatures(msrest.serialization.Model): +class SubscriptionRegisteredFeatures(_serialization.Model): """SubscriptionRegisteredFeatures. - :param name: - :type name: str - :param state: - :type state: str + :ivar name: + :vartype name: str + :ivar state: + :vartype state: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - state: Optional[str] = None, - **kwargs - ): - super(SubscriptionRegisteredFeatures, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, state: Optional[str] = None, **kwargs): + """ + :keyword name: + :paramtype name: str + :keyword state: + :paramtype state: str + """ + super().__init__(**kwargs) self.name = name self.state = state -class SymmetricKey(msrest.serialization.Model): +class SymmetricKey(_serialization.Model): """Symmetric key for authentication. - :param connection_string: Connection string based on the symmetric key. - :type connection_string: + :ivar connection_string: Connection string based on the symmetric key. + :vartype connection_string: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret """ _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, + "connection_string": {"key": "connectionString", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) + def __init__(self, *, connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs): + """ + :keyword connection_string: Connection string based on the symmetric key. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.connection_string = connection_string -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or + ~azure.mgmt.databoxedge.v2020_09_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", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The type of identity that last modified the resource. + :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'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_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, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(SystemData, self).__init__(**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", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.databoxedge.v2020_09_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", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.CreatedByType + :keyword last_modified_at: The type of identity that last modified the resource. + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -4841,24 +5260,24 @@ def __init__( self.last_modified_at = last_modified_at -class TrackingInfo(msrest.serialization.Model): +class TrackingInfo(_serialization.Model): """Tracking courier information. - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str + :ivar serial_number: Serial number of the device being tracked. + :vartype serial_number: str + :ivar carrier_name: Name of the carrier used in the delivery. + :vartype carrier_name: str + :ivar tracking_id: Tracking ID of the shipment. + :vartype tracking_id: str + :ivar tracking_url: Tracking URL of the shipment. + :vartype tracking_url: str """ _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, + "serial_number": {"key": "serialNumber", "type": "str"}, + "carrier_name": {"key": "carrierName", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "tracking_url": {"key": "trackingUrl", "type": "str"}, } def __init__( @@ -4870,14 +5289,24 @@ def __init__( tracking_url: Optional[str] = None, **kwargs ): - super(TrackingInfo, self).__init__(**kwargs) + """ + :keyword serial_number: Serial number of the device being tracked. + :paramtype serial_number: str + :keyword carrier_name: Name of the carrier used in the delivery. + :paramtype carrier_name: str + :keyword tracking_id: Tracking ID of the shipment. + :paramtype tracking_id: str + :keyword tracking_url: Tracking URL of the shipment. + :paramtype tracking_url: str + """ + super().__init__(**kwargs) self.serial_number = serial_number self.carrier_name = carrier_name self.tracking_id = tracking_id self.tracking_url = tracking_url -class TriggerList(msrest.serialization.Model): +class TriggerList(_serialization.Model): """Collection of all trigger on the data box edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4889,31 +5318,29 @@ class TriggerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Trigger]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class UpdateDownloadProgress(msrest.serialization.Model): +class UpdateDownloadProgress(_serialization.Model): """Details about the download progress of update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". + :ivar download_phase: The download phase. Known values are: "Unknown", "Initializing", + "Downloading", and "Verifying". :vartype download_phase: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DownloadPhase :ivar percent_complete: Percentage of completion. @@ -4929,28 +5356,26 @@ class UpdateDownloadProgress(msrest.serialization.Model): """ _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, + "download_phase": {"readonly": True}, + "percent_complete": {"readonly": True}, + "total_bytes_to_download": {"readonly": True}, + "total_bytes_downloaded": {"readonly": True}, + "number_of_updates_to_download": {"readonly": True}, + "number_of_updates_downloaded": {"readonly": True}, } _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, + "download_phase": {"key": "downloadPhase", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "total_bytes_to_download": {"key": "totalBytesToDownload", "type": "float"}, + "total_bytes_downloaded": {"key": "totalBytesDownloaded", "type": "float"}, + "number_of_updates_to_download": {"key": "numberOfUpdatesToDownload", "type": "int"}, + "number_of_updates_downloaded": {"key": "numberOfUpdatesDownloaded", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.download_phase = None self.percent_complete = None self.total_bytes_to_download = None @@ -4959,7 +5384,7 @@ def __init__( self.number_of_updates_downloaded = None -class UpdateInstallProgress(msrest.serialization.Model): +class UpdateInstallProgress(_serialization.Model): """Progress details during installation of updates. Variables are only populated by the server, and will be ignored when sending a request. @@ -4973,28 +5398,26 @@ class UpdateInstallProgress(msrest.serialization.Model): """ _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, + "percent_complete": {"readonly": True}, + "number_of_updates_to_install": {"readonly": True}, + "number_of_updates_installed": {"readonly": True}, } _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "number_of_updates_to_install": {"key": "numberOfUpdatesToInstall", "type": "int"}, + "number_of_updates_installed": {"key": "numberOfUpdatesInstalled", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.percent_complete = None self.number_of_updates_to_install = None self.number_of_updates_installed = None -class UpdateSummary(ARMBaseModel): +class UpdateSummary(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Details about ongoing updates and availability of updates on the device. Variables are only populated by the server, and will be ignored when sending a request. @@ -5005,15 +5428,15 @@ class UpdateSummary(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed + :ivar device_version_number: The current version of the device in format: 1.2.17312.13.",. + :vartype device_version_number: str + :ivar friendly_device_version_name: The current version of the device in text format. + :vartype friendly_device_version_name: str + :ivar device_last_scanned_date_time: The last time when a scan was done on the device. + :vartype device_last_scanned_date_time: ~datetime.datetime + :ivar last_completed_scan_job_date_time: The time when the last scan job was completed (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime + :vartype last_completed_scan_job_date_time: ~datetime.datetime :ivar last_completed_download_job_date_time: The time when the last Download job was completed (success/cancelled/failed) on the appliance. :vartype last_completed_download_job_date_time: ~datetime.datetime @@ -5028,11 +5451,11 @@ class UpdateSummary(ARMBaseModel): :ivar total_number_of_updates_pending_install: The total number of items pending install. :vartype total_number_of_updates_pending_install: int :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". + :ivar ongoing_update_operation: The current update operation. Known values are: "None", "Scan", + "Download", and "Install". :vartype ongoing_update_operation: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UpdateOperation :ivar in_progress_download_job_id: The job ID of the download job in progress. @@ -5052,45 +5475,63 @@ class UpdateSummary(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_completed_download_job_date_time": {"readonly": True}, + "last_completed_install_job_date_time": {"readonly": True}, + "total_number_of_updates_available": {"readonly": True}, + "total_number_of_updates_pending_download": {"readonly": True}, + "total_number_of_updates_pending_install": {"readonly": True}, + "reboot_behavior": {"readonly": True}, + "ongoing_update_operation": {"readonly": True}, + "in_progress_download_job_id": {"readonly": True}, + "in_progress_install_job_id": {"readonly": True}, + "in_progress_download_job_started_date_time": {"readonly": True}, + "in_progress_install_job_started_date_time": {"readonly": True}, + "update_titles": {"readonly": True}, + "total_update_size_in_bytes": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_version_number": {"key": "properties.deviceVersionNumber", "type": "str"}, + "friendly_device_version_name": {"key": "properties.friendlyDeviceVersionName", "type": "str"}, + "device_last_scanned_date_time": {"key": "properties.deviceLastScannedDateTime", "type": "iso-8601"}, + "last_completed_scan_job_date_time": {"key": "properties.lastCompletedScanJobDateTime", "type": "iso-8601"}, + "last_completed_download_job_date_time": { + "key": "properties.lastCompletedDownloadJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_date_time": { + "key": "properties.lastCompletedInstallJobDateTime", + "type": "iso-8601", + }, + "total_number_of_updates_available": {"key": "properties.totalNumberOfUpdatesAvailable", "type": "int"}, + "total_number_of_updates_pending_download": { + "key": "properties.totalNumberOfUpdatesPendingDownload", + "type": "int", + }, + "total_number_of_updates_pending_install": { + "key": "properties.totalNumberOfUpdatesPendingInstall", + "type": "int", + }, + "reboot_behavior": {"key": "properties.rebootBehavior", "type": "str"}, + "ongoing_update_operation": {"key": "properties.ongoingUpdateOperation", "type": "str"}, + "in_progress_download_job_id": {"key": "properties.inProgressDownloadJobId", "type": "str"}, + "in_progress_install_job_id": {"key": "properties.inProgressInstallJobId", "type": "str"}, + "in_progress_download_job_started_date_time": { + "key": "properties.inProgressDownloadJobStartedDateTime", + "type": "iso-8601", + }, + "in_progress_install_job_started_date_time": { + "key": "properties.inProgressInstallJobStartedDateTime", + "type": "iso-8601", + }, + "update_titles": {"key": "properties.updateTitles", "type": "[str]"}, + "total_update_size_in_bytes": {"key": "properties.totalUpdateSizeInBytes", "type": "float"}, } def __init__( @@ -5102,7 +5543,18 @@ def __init__( last_completed_scan_job_date_time: Optional[datetime.datetime] = None, **kwargs ): - super(UpdateSummary, self).__init__(**kwargs) + """ + :keyword device_version_number: The current version of the device in format: 1.2.17312.13.",. + :paramtype device_version_number: str + :keyword friendly_device_version_name: The current version of the device in text format. + :paramtype friendly_device_version_name: str + :keyword device_last_scanned_date_time: The last time when a scan was done on the device. + :paramtype device_last_scanned_date_time: ~datetime.datetime + :keyword last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :paramtype last_completed_scan_job_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.device_version_number = device_version_number self.friendly_device_version_name = friendly_device_version_name self.device_last_scanned_date_time = device_last_scanned_date_time @@ -5122,48 +5574,57 @@ def __init__( self.total_update_size_in_bytes = None -class UploadCertificateRequest(msrest.serialization.Model): +class UploadCertificateRequest(_serialization.Model): """The upload certificate request. All required parameters must be populated in order to send to Azure. - :param authentication_type: The authentication type. Possible values include: "Invalid", + :ivar authentication_type: The authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type authentication_type: str or + :vartype authentication_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str + :ivar certificate: The base64 encoded certificate raw data. Required. + :vartype certificate: str """ _validation = { - 'certificate': {'required': True}, + "certificate": {"required": True}, } _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "certificate": {"key": "properties.certificate", "type": "str"}, } def __init__( self, *, certificate: str, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs ): - super(UploadCertificateRequest, self).__init__(**kwargs) + """ + :keyword authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype authentication_type: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AuthenticationType + :keyword certificate: The base64 encoded certificate raw data. Required. + :paramtype certificate: str + """ + super().__init__(**kwargs) self.authentication_type = authentication_type self.certificate = certificate -class UploadCertificateResponse(msrest.serialization.Model): +class UploadCertificateResponse(_serialization.Model): """The upload registration certificate response. Variables are only populated by the server, and will be ignored when sending a request. - :param auth_type: Specifies authentication type. Possible values include: "Invalid", + :ivar auth_type: Specifies authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AuthenticationType + :vartype auth_type: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AuthenticationType :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. :vartype resource_id: str :ivar aad_authority: Azure Active Directory tenant authority. @@ -5182,33 +5643,34 @@ class UploadCertificateResponse(msrest.serialization.Model): """ _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, + "resource_id": {"readonly": True}, + "aad_authority": {"readonly": True}, + "aad_tenant_id": {"readonly": True}, + "service_principal_client_id": {"readonly": True}, + "service_principal_object_id": {"readonly": True}, + "azure_management_endpoint_audience": {"readonly": True}, + "aad_audience": {"readonly": True}, } _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - *, - auth_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) + "auth_type": {"key": "authType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "aad_authority": {"key": "aadAuthority", "type": "str"}, + "aad_tenant_id": {"key": "aadTenantId", "type": "str"}, + "service_principal_client_id": {"key": "servicePrincipalClientId", "type": "str"}, + "service_principal_object_id": {"key": "servicePrincipalObjectId", "type": "str"}, + "azure_management_endpoint_audience": {"key": "azureManagementEndpointAudience", "type": "str"}, + "aad_audience": {"key": "aadAudience", "type": "str"}, + } + + def __init__(self, *, auth_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs): + """ + :keyword auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype auth_type: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AuthenticationType + """ + super().__init__(**kwargs) self.auth_type = auth_type self.resource_id = None self.aad_authority = None @@ -5232,84 +5694,93 @@ class User(ARMBaseModel): :vartype type: str :ivar system_data: User in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SystemData - :param encrypted_password: The password details. - :type encrypted_password: + :ivar encrypted_password: The password details. + :vartype encrypted_password: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret :ivar share_access_rights: List of shares that the user has rights on. This field should not be specified during user creation. :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessRight] - :param user_type: Type of the user. Possible values include: "Share", "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UserType + :ivar user_type: Type of the user. Known values are: "Share", "LocalManagement", and "ARM". + :vartype user_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UserType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_access_rights': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_access_rights": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "encrypted_password": {"key": "properties.encryptedPassword", "type": "AsymmetricEncryptedSecret"}, + "share_access_rights": {"key": "properties.shareAccessRights", "type": "[ShareAccessRight]"}, + "user_type": {"key": "properties.userType", "type": "str"}, } def __init__( self, *, - encrypted_password: Optional["AsymmetricEncryptedSecret"] = None, - user_type: Optional[Union[str, "UserType"]] = None, + encrypted_password: Optional["_models.AsymmetricEncryptedSecret"] = None, + user_type: Optional[Union[str, "_models.UserType"]] = None, **kwargs ): - super(User, self).__init__(**kwargs) + """ + :keyword encrypted_password: The password details. + :paramtype encrypted_password: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.AsymmetricEncryptedSecret + :keyword user_type: Type of the user. Known values are: "Share", "LocalManagement", and "ARM". + :paramtype user_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UserType + """ + super().__init__(**kwargs) self.system_data = None self.encrypted_password = encrypted_password self.share_access_rights = None self.user_type = user_type -class UserAccessRight(msrest.serialization.Model): +class UserAccessRight(_serialization.Model): """The mapping between a particular user and the access type on the SMB share. All required parameters must be populated in order to send to Azure. - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessType + :ivar user_id: User ID (already existing in the device). Required. + :vartype user_id: str + :ivar access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessType """ _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, + "user_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - user_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) + "user_id": {"key": "userId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, user_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword user_id: User ID (already existing in the device). Required. + :paramtype user_id: str + :keyword access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :paramtype access_type: str or + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareAccessType + """ + super().__init__(**kwargs) self.user_id = user_id self.access_type = access_type -class UserList(msrest.serialization.Model): +class UserList(_serialization.Model): """Collection of users. Variables are only populated by the server, and will be ignored when sending a request. @@ -5321,19 +5792,17 @@ class UserList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[User]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/__init__.py index d70057be6458..febac852eb27 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/__init__.py @@ -25,23 +25,29 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'AddonsOperations', - 'MonitoringConfigOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_addons_operations.py index 9365bc2d7256..6b206f223bee 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_addons_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,114 +6,284 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_role_request( + device_name: str, role_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, addon_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AddonsOperations(object): - """AddonsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`addons` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_role( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AddonList"] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Addon"]: """Lists all the addons configured in the role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AddonList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_role.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,122 +292,137 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_role.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + @distributed_trace def get( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Addon" + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: """Gets a specific addon by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } def _create_or_update_initial( self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Addon"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Addon"]] + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(addon, 'Addon') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -245,53 +431,145 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Addon"] + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: """Create or update a addon. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param addon: The addon properties. + :param addon: The addon properties. Required. :type addon: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Addon or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -299,80 +577,77 @@ def begin_create_or_update( addon_name=addon_name, resource_group_name=resource_group_name, addon=addon, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -382,79 +657,81 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the addon on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, addon_name=addon_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_alerts_operations.py index 5621d275fc8f..b243a79cbe86 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,204 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class AlertsOperations(object): - """AlertsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_by_data_box_edge_device_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,72 +212,75 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_available_skus_operations.py index 07119aad4c34..3781d0ad7b3c 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,158 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } -class AvailableSkusOperations(object): - """AvailableSkusOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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 AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeSkuList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,7 +166,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_bandwidth_schedules_operations.py index 9d8a3cd35b81..4a27bc89e2a9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,278 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class BandwidthSchedulesOperations(object): - """BandwidthSchedulesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BandwidthSchedulesList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +286,130 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BandwidthSchedule" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BandwidthSchedule"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +418,219 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BandwidthSchedule"] + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +640,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_containers_operations.py index 5e8e117e34fe..0cb31c996e21 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,342 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_storage_account_request( + device_name: str, storage_account_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ContainersOperations(object): - """ContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_storage_account( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ContainerList"] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,124 +350,139 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Container" + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Container"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -249,55 +491,154 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Container"] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Container or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -305,80 +646,77 @@ def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -388,121 +726,120 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -512,81 +849,81 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace def begin_refresh( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_devices_operations.py index a058fb8f62d2..acf1761c6b94 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,680 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", + ) # 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"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_download_updates_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_generate_certificate_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_extended_information_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations(object): - """DevicesOperations operations. +def build_install_updates_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_settings_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_scan_for_updates_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_security_settings_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_update_extended_information_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_get_update_summary_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_upload_certificate_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_subscription( - self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,75 +688,92 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,230 +782,335 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } def _create_or_update_initial( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. - :type data_box_edge_device: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -425,174 +1120,250 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload def update( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDevicePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevicePatch or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - def _download_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -602,227 +1373,240 @@ def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } - def begin_download_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_download_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._download_updates_initial( + raw_result = self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace def generate_certificate( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GenerateCertResponse" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: """Generates certificate for activation key. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenerateCertResponse, or the result of cls(response) + :return: GenerateCertResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.GenerateCertResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCertResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.generate_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateCertResponse', pipeline_response) + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate'} # type: ignore + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace def get_extended_information( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - def _install_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -832,168 +1616,176 @@ def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } - def begin_install_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_install_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._install_updates_initial( + raw_result = self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace def get_network_settings( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkSettings" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - def _scan_for_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1003,115 +1795,128 @@ def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def begin_scan_for_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_scan_for_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._scan_for_updates_initial( + raw_result = self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _create_or_update_security_settings_initial( + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + + def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1121,269 +1926,502 @@ def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload def begin_create_or_update_security_settings( self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.SecuritySettings or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_security_settings_initial( + raw_result = self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload def update_extended_information( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDeviceExtendedInfoPatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The patch object. - :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDeviceExtendedInfoPatch') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation'} # type: ignore - def get_update_summary( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateSummary" - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace + def get_update_summary(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload def upload_certificate( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.UploadCertificateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.UploadCertificateResponse" + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_jobs_operations.py index 3093099186b6..a1c173f0a84f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class JobsOperations(object): - """JobsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_monitoring_config_operations.py index dfe56fe7e990..f5f9f7ebcc57 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_monitoring_config_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_monitoring_config_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,285 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + device_name: str, role_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class MonitoringConfigOperations(object): - """MonitoringConfigOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MonitoringMetricConfigurationList"] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.MonitoringMetricConfiguration"]: """Lists metric configurations in a role. Lists metric configurations in a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 MonitoringMetricConfigurationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfigurationList', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,118 +293,134 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + + @distributed_trace def get( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MonitoringMetricConfiguration" + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: """Gets a metric configuration of a role. Gets a metric configuration of a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringMetricConfiguration, or the result of cls(response) + :return: MonitoringMetricConfiguration or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } def _create_or_update_initial( self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - monitoring_metric_configuration, # type: "_models.MonitoringMetricConfiguration" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MonitoringMetricConfiguration"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MonitoringMetricConfiguration"]] + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(monitoring_metric_configuration, 'MonitoringMetricConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -243,129 +429,227 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace def begin_create_or_update( self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - monitoring_metric_configuration, # type: "_models.MonitoringMetricConfiguration" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MonitoringMetricConfiguration"] + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: """Creates a new metric configuration or updates an existing one for a role. Creates a new metric configuration or updates an existing one for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param monitoring_metric_configuration: The metric configuration. - :type monitoring_metric_configuration: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.MonitoringMetricConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, monitoring_metric_configuration=monitoring_metric_configuration, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) - + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -375,76 +659,78 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """deletes a new metric configuration for a role. deletes a new metric configuration for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_nodes_operations.py index 64bd64238045..0fb4eba4bf89 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,170 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class NodesOperations(object): - """NodesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NodeList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +178,8 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_operations.py index 9a70248228a1..0fcde06ab8df 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataBoxEdge/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +160,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_operations_status_operations.py index 16307b29fbfb..491e7dd92f1b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class OperationsStatusOperations(object): - """OperationsStatusOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_orders_operations.py index 603494a81f39..1fd4f5a3b847 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,307 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request(device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class OrdersOperations(object): - """OrdersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_dc_access_code_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OrderList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,112 +315,123 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Order" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } def _create_or_update_initial( - self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Order"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,122 +440,204 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Order"] + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,132 +647,137 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def list_dc_access_code( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DCAccessCode" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace + def list_dc_access_code(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DCAccessCode: """Gets the DCAccess Code. Gets the DCAccess Code. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DCAccessCode, or the result of cls(response) + :return: DCAccessCode or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.DCAccessCode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DCAccessCode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_dc_access_code.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DCAccessCode', pipeline_response) + deserialized = self._deserialize("DCAccessCode", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_dc_access_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode'} # type: ignore + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_roles_operations.py index 2a5c33e838ce..76163558e9fe 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RolesOperations(object): - """RolesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +285,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Role" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Role"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +412,207 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Role"] + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +622,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_shares_operations.py index 501d30d91ea7..6ff21d7a4649 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,313 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class SharesOperations(object): - """SharesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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 SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ShareList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +321,127 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Share" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Share"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +450,213 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Share"] + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,114 +666,114 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -488,76 +783,76 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } - def begin_refresh( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_refresh(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_storage_account_credentials_operations.py index 5f47caaaf368..a52b191a5072 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,281 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class StorageAccountCredentialsOperations(object): - """StorageAccountCredentialsOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountCredentialList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,116 +289,132 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountCredential" + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccountCredential"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -237,127 +423,221 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccountCredential"] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -367,74 +647,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_storage_accounts_operations.py index 0aac41580fed..6f1b22f5cefd 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,280 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, storage_account_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, storage_account_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, storage_account_name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccount"]: """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +288,134 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccount" + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccount"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +424,225 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccount"] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -371,74 +652,76 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_triggers_operations.py index 107270847ee8..7dcf7723c077 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,284 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TriggersOperations(object): - """TriggersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TriggerList"] + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +292,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Trigger" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Trigger"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,127 +419,210 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Trigger"] + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Trigger or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +632,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_users_operations.py index 569bcc44fd46..7d39f4fdc9da 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_09_01_preview/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,284 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class UsersOperations(object): - """UsersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2020_09_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2020_09_01_preview.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserList"] + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +292,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.User"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,128 +419,210 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.User"] + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2020_09_01_preview.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2020_09_01_preview.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -372,74 +632,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2020-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-09-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/__init__.py new file mode 100644 index 000000000000..d2bcf6a47896 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._data_box_edge_management_client import DataBoxEdgeManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_configuration.py new file mode 100644 index 000000000000..7bee31156957 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_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. +# -------------------------------------------------------------------------- + +import sys +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 sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for DataBoxEdgeManagementClient. + + 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. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription ID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", "2021-02-01") + + 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-databoxedge/{}".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.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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_data_box_edge_management_client.py new file mode 100644 index 000000000000..13cecaa3b883 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_data_box_edge_management_client.py @@ -0,0 +1,190 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + DiagnosticSettingsOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + SupportPackagesOperations, + TriggersOperations, + UsersOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The DataBoxEdge Client. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.databoxedge.v2021_02_01.operations.Operations + :ivar available_skus: AvailableSkusOperations operations + :vartype available_skus: azure.mgmt.databoxedge.v2021_02_01.operations.AvailableSkusOperations + :ivar devices: DevicesOperations operations + :vartype devices: azure.mgmt.databoxedge.v2021_02_01.operations.DevicesOperations + :ivar alerts: AlertsOperations operations + :vartype alerts: azure.mgmt.databoxedge.v2021_02_01.operations.AlertsOperations + :ivar bandwidth_schedules: BandwidthSchedulesOperations operations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2021_02_01.operations.BandwidthSchedulesOperations + :ivar diagnostic_settings: DiagnosticSettingsOperations operations + :vartype diagnostic_settings: + azure.mgmt.databoxedge.v2021_02_01.operations.DiagnosticSettingsOperations + :ivar jobs: JobsOperations operations + :vartype jobs: azure.mgmt.databoxedge.v2021_02_01.operations.JobsOperations + :ivar nodes: NodesOperations operations + :vartype nodes: azure.mgmt.databoxedge.v2021_02_01.operations.NodesOperations + :ivar operations_status: OperationsStatusOperations operations + :vartype operations_status: + azure.mgmt.databoxedge.v2021_02_01.operations.OperationsStatusOperations + :ivar orders: OrdersOperations operations + :vartype orders: azure.mgmt.databoxedge.v2021_02_01.operations.OrdersOperations + :ivar roles: RolesOperations operations + :vartype roles: azure.mgmt.databoxedge.v2021_02_01.operations.RolesOperations + :ivar addons: AddonsOperations operations + :vartype addons: azure.mgmt.databoxedge.v2021_02_01.operations.AddonsOperations + :ivar monitoring_config: MonitoringConfigOperations operations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2021_02_01.operations.MonitoringConfigOperations + :ivar shares: SharesOperations operations + :vartype shares: azure.mgmt.databoxedge.v2021_02_01.operations.SharesOperations + :ivar storage_account_credentials: StorageAccountCredentialsOperations operations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2021_02_01.operations.StorageAccountCredentialsOperations + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2021_02_01.operations.StorageAccountsOperations + :ivar containers: ContainersOperations operations + :vartype containers: azure.mgmt.databoxedge.v2021_02_01.operations.ContainersOperations + :ivar triggers: TriggersOperations operations + :vartype triggers: azure.mgmt.databoxedge.v2021_02_01.operations.TriggersOperations + :ivar support_packages: SupportPackagesOperations operations + :vartype support_packages: + azure.mgmt.databoxedge.v2021_02_01.operations.SupportPackagesOperations + :ivar users: UsersOperations operations + :vartype users: azure.mgmt.databoxedge.v2021_02_01.operations.UsersOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription ID. Required. + :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". 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 = DataBoxEdgeManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.bandwidth_schedules = BandwidthSchedulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings = DiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations_status = OperationsStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_config = MonitoringConfigOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_account_credentials = StorageAccountCredentialsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.support_packages = SupportPackagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.users = UsersOperations(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/dpcodegen/python/send_request + + :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) -> None: + self._client.close() + + def __enter__(self) -> "DataBoxEdgeManagementClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_metadata.json b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_metadata.json new file mode 100644 index 000000000000..37d732b2b011 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_metadata.json @@ -0,0 +1,121 @@ +{ + "chosen_version": "2021-02-01", + "total_api_version_list": ["2021-02-01"], + "client": { + "name": "DataBoxEdgeManagementClient", + "filename": "_data_box_edge_management_client", + "description": "The DataBoxEdge Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "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 + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "available_skus": "AvailableSkusOperations", + "devices": "DevicesOperations", + "alerts": "AlertsOperations", + "bandwidth_schedules": "BandwidthSchedulesOperations", + "diagnostic_settings": "DiagnosticSettingsOperations", + "jobs": "JobsOperations", + "nodes": "NodesOperations", + "operations_status": "OperationsStatusOperations", + "orders": "OrdersOperations", + "roles": "RolesOperations", + "addons": "AddonsOperations", + "monitoring_config": "MonitoringConfigOperations", + "shares": "SharesOperations", + "storage_account_credentials": "StorageAccountCredentialsOperations", + "storage_accounts": "StorageAccountsOperations", + "containers": "ContainersOperations", + "triggers": "TriggersOperations", + "support_packages": "SupportPackagesOperations", + "users": "UsersOperations" + } +} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_vendor.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_version.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/__init__.py new file mode 100644 index 000000000000..fcb8775eaa10 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/__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 ._data_box_edge_management_client import DataBoxEdgeManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_configuration.py new file mode 100644 index 000000000000..1946c0d7bf79 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_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. +# -------------------------------------------------------------------------- + +import sys +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 sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for DataBoxEdgeManagementClient. + + 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. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription ID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", "2021-02-01") + + 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-databoxedge/{}".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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_data_box_edge_management_client.py new file mode 100644 index 000000000000..c16506a53faa --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_data_box_edge_management_client.py @@ -0,0 +1,191 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + DiagnosticSettingsOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + SupportPackagesOperations, + TriggersOperations, + UsersOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The DataBoxEdge Client. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.databoxedge.v2021_02_01.aio.operations.Operations + :ivar available_skus: AvailableSkusOperations operations + :vartype available_skus: + azure.mgmt.databoxedge.v2021_02_01.aio.operations.AvailableSkusOperations + :ivar devices: DevicesOperations operations + :vartype devices: azure.mgmt.databoxedge.v2021_02_01.aio.operations.DevicesOperations + :ivar alerts: AlertsOperations operations + :vartype alerts: azure.mgmt.databoxedge.v2021_02_01.aio.operations.AlertsOperations + :ivar bandwidth_schedules: BandwidthSchedulesOperations operations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2021_02_01.aio.operations.BandwidthSchedulesOperations + :ivar diagnostic_settings: DiagnosticSettingsOperations operations + :vartype diagnostic_settings: + azure.mgmt.databoxedge.v2021_02_01.aio.operations.DiagnosticSettingsOperations + :ivar jobs: JobsOperations operations + :vartype jobs: azure.mgmt.databoxedge.v2021_02_01.aio.operations.JobsOperations + :ivar nodes: NodesOperations operations + :vartype nodes: azure.mgmt.databoxedge.v2021_02_01.aio.operations.NodesOperations + :ivar operations_status: OperationsStatusOperations operations + :vartype operations_status: + azure.mgmt.databoxedge.v2021_02_01.aio.operations.OperationsStatusOperations + :ivar orders: OrdersOperations operations + :vartype orders: azure.mgmt.databoxedge.v2021_02_01.aio.operations.OrdersOperations + :ivar roles: RolesOperations operations + :vartype roles: azure.mgmt.databoxedge.v2021_02_01.aio.operations.RolesOperations + :ivar addons: AddonsOperations operations + :vartype addons: azure.mgmt.databoxedge.v2021_02_01.aio.operations.AddonsOperations + :ivar monitoring_config: MonitoringConfigOperations operations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2021_02_01.aio.operations.MonitoringConfigOperations + :ivar shares: SharesOperations operations + :vartype shares: azure.mgmt.databoxedge.v2021_02_01.aio.operations.SharesOperations + :ivar storage_account_credentials: StorageAccountCredentialsOperations operations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2021_02_01.aio.operations.StorageAccountCredentialsOperations + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2021_02_01.aio.operations.StorageAccountsOperations + :ivar containers: ContainersOperations operations + :vartype containers: azure.mgmt.databoxedge.v2021_02_01.aio.operations.ContainersOperations + :ivar triggers: TriggersOperations operations + :vartype triggers: azure.mgmt.databoxedge.v2021_02_01.aio.operations.TriggersOperations + :ivar support_packages: SupportPackagesOperations operations + :vartype support_packages: + azure.mgmt.databoxedge.v2021_02_01.aio.operations.SupportPackagesOperations + :ivar users: UsersOperations operations + :vartype users: azure.mgmt.databoxedge.v2021_02_01.aio.operations.UsersOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription ID. Required. + :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". 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 = DataBoxEdgeManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.bandwidth_schedules = BandwidthSchedulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings = DiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations_status = OperationsStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitoring_config = MonitoringConfigOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_account_credentials = StorageAccountCredentialsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.support_packages = SupportPackagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.users = UsersOperations(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/dpcodegen/python/send_request + + :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) -> "DataBoxEdgeManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/__init__.py new file mode 100644 index 000000000000..29c0c74f0582 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/__init__.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 ._operations import Operations +from ._available_skus_operations import AvailableSkusOperations +from ._devices_operations import DevicesOperations +from ._alerts_operations import AlertsOperations +from ._bandwidth_schedules_operations import BandwidthSchedulesOperations +from ._diagnostic_settings_operations import DiagnosticSettingsOperations +from ._jobs_operations import JobsOperations +from ._nodes_operations import NodesOperations +from ._operations_status_operations import OperationsStatusOperations +from ._orders_operations import OrdersOperations +from ._roles_operations import RolesOperations +from ._addons_operations import AddonsOperations +from ._monitoring_config_operations import MonitoringConfigOperations +from ._shares_operations import SharesOperations +from ._storage_account_credentials_operations import StorageAccountCredentialsOperations +from ._storage_accounts_operations import StorageAccountsOperations +from ._containers_operations import ContainersOperations +from ._triggers_operations import TriggersOperations +from ._support_packages_operations import SupportPackagesOperations +from ._users_operations import UsersOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "DiagnosticSettingsOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "SupportPackagesOperations", + "UsersOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_addons_operations.py new file mode 100644 index 000000000000..c978f6499334 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_addons_operations.py @@ -0,0 +1,585 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._addons_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_role_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`addons` 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 + def list_by_role( + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Addon"]: + """Lists all the addons configured in the role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :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 Addon or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AddonList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + + @distributed_trace_async + async def get( + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: + """Gets a specific addon by name. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Addon or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Addon + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Addon", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + async def _create_or_update_initial( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Addon", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: ~azure.mgmt.databoxedge.v2021_02_01.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2021_02_01.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + addon=addon, + 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("Addon", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the addon on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_alerts_operations.py new file mode 100644 index 000000000000..a24b30fbf45b --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_alerts_operations.py @@ -0,0 +1,214 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._alerts_operations import build_get_request, build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`alerts` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: + """Gets all the alerts for a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Alert or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: + """Gets an alert by name. + + Gets an alert by name. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The alert name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Alert + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Alert", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_available_skus_operations.py new file mode 100644 index 000000000000..0650410139e3 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_available_skus_operations.py @@ -0,0 +1,140 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._available_skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`available_skus` 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 + def list(self, **kwargs: Any) -> AsyncIterable["_models.DataBoxEdgeSku"]: + """List all the available Skus and information related to them. + + List all the available Skus and information related to them. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_bandwidth_schedules_operations.py new file mode 100644 index 000000000000..4a1a440055cd --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_bandwidth_schedules_operations.py @@ -0,0 +1,570 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._bandwidth_schedules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BandwidthSchedule"]: + """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace_async + async def get( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.BandwidthSchedule: + """Gets the properties of the specified bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BandwidthSchedule or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _create_or_update_initial( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_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("BandwidthSchedule", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_containers_operations.py new file mode 100644 index 000000000000..5b617eef7e61 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_containers_operations.py @@ -0,0 +1,723 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._containers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_storage_account_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`containers` 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 + def list_by_storage_account( + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Container"]: + """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. + + Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The storage Account name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :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 Container or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ContainerList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + + @distributed_trace_async + async def get( + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: + """Gets a container by name. + + Gets a container by name. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container Name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Container or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Container + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Container", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _create_or_update_initial( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Container", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: ~azure.mgmt.databoxedge.v2021_02_01.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2021_02_01.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + container=container, + 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("Container", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the container on the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + + @distributed_trace_async + async def begin_refresh( + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refreshes the container metadata with the data from the cloud. + + Refreshes the container metadata with the data from the cloud. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._refresh_initial( # type: ignore + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_devices_operations.py new file mode 100644 index 000000000000..8800a2b3870d --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_devices_operations.py @@ -0,0 +1,1777 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._devices_operations import ( + build_create_or_update_request, + build_create_or_update_security_settings_request, + build_delete_request, + build_download_updates_request, + build_generate_certificate_request, + build_get_extended_information_request, + build_get_network_settings_request, + build_get_request, + build_get_update_summary_request, + build_install_updates_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_scan_for_updates_request, + build_update_extended_information_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`devices` 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 + def list_by_subscription( + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: + """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. + + :param expand: Specify $expand=details to populate additional fields related to the resource or + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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, + expand=expand, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: + """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param expand: Specify $expand=details to populate additional fields related to the resource or + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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, + expand=expand, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: + """Gets the properties of the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload + async def create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace_async + async def begin_download_updates( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Downloads the updates on a Data Box Edge/Data Box Gateway device. + + Downloads the updates on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._download_updates_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace_async + async def generate_certificate( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: + """Generates certificate for activation key. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenerateCertResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.GenerateCertResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace_async + async def get_extended_information( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + async def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + + @distributed_trace_async + async def begin_install_updates( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Installs the updates on the Data Box Edge/Data Box Gateway device. + + Installs the updates on the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._install_updates_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + + @distributed_trace_async + async def get_network_settings( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: + """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkSettings or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.NetworkSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkSettings", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + async def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + + @distributed_trace_async + async def begin_scan_for_updates( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Scans for updates on a Data Box Edge/Data Box Gateway device. + + Scans for updates on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._scan_for_updates_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + + async def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2021_02_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2021_02_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_security_settings_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_name, + security_settings=security_settings, + 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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfoPatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace_async + async def get_update_summary( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. + + Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UpdateSummary or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateSummary + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateSummary", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_diagnostic_settings_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_diagnostic_settings_operations.py new file mode 100644 index 000000000000..9fa298b0dc24 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_diagnostic_settings_operations.py @@ -0,0 +1,609 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._diagnostic_settings_operations import ( + build_get_diagnostic_proactive_log_collection_settings_request, + build_get_diagnostic_remote_support_settings_request, + build_update_diagnostic_proactive_log_collection_settings_request, + build_update_diagnostic_remote_support_settings_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`diagnostic_settings` 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_diagnostic_proactive_log_collection_settings( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DiagnosticProactiveLogCollectionSettings: + """Gets the proactive log collection settings of the specified Data Box Edge/Data Box Gateway + device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticProactiveLogCollectionSettings or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticProactiveLogCollectionSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DiagnosticProactiveLogCollectionSettings] = kwargs.pop("cls", None) + + request = build_get_diagnostic_proactive_log_collection_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_diagnostic_proactive_log_collection_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticProactiveLogCollectionSettings", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_diagnostic_proactive_log_collection_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticProactiveLogCollectionSettings/default" + } + + async def _update_diagnostic_proactive_log_collection_settings_initial( # pylint: disable=inconsistent-return-statements + self, + device_name: str, + resource_group_name: str, + proactive_log_collection_settings: Union[_models.DiagnosticProactiveLogCollectionSettings, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(proactive_log_collection_settings, (IO, bytes)): + _content = proactive_log_collection_settings + else: + _json = self._serialize.body(proactive_log_collection_settings, "DiagnosticProactiveLogCollectionSettings") + + request = build_update_diagnostic_proactive_log_collection_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_diagnostic_proactive_log_collection_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _update_diagnostic_proactive_log_collection_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticProactiveLogCollectionSettings/default" + } + + @overload + async def begin_update_diagnostic_proactive_log_collection_settings( + self, + device_name: str, + resource_group_name: str, + proactive_log_collection_settings: _models.DiagnosticProactiveLogCollectionSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the proactive log collection settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param proactive_log_collection_settings: The proactive log collection settings. Required. + :type proactive_log_collection_settings: + ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticProactiveLogCollectionSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @overload + async def begin_update_diagnostic_proactive_log_collection_settings( + self, + device_name: str, + resource_group_name: str, + proactive_log_collection_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the proactive log collection settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param proactive_log_collection_settings: The proactive log collection settings. Required. + :type proactive_log_collection_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_update_diagnostic_proactive_log_collection_settings( + self, + device_name: str, + resource_group_name: str, + proactive_log_collection_settings: Union[_models.DiagnosticProactiveLogCollectionSettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the proactive log collection settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param proactive_log_collection_settings: The proactive log collection settings. Is either a + model type or a IO type. Required. + :type proactive_log_collection_settings: + ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticProactiveLogCollectionSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_diagnostic_proactive_log_collection_settings_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_name, + proactive_log_collection_settings=proactive_log_collection_settings, + 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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_update_diagnostic_proactive_log_collection_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticProactiveLogCollectionSettings/default" + } + + @distributed_trace_async + async def get_diagnostic_remote_support_settings( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DiagnosticRemoteSupportSettings: + """Gets the diagnostic remote support settings of the specified Data Box Edge/Data Box Gateway + device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticRemoteSupportSettings or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticRemoteSupportSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DiagnosticRemoteSupportSettings] = kwargs.pop("cls", None) + + request = build_get_diagnostic_remote_support_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_diagnostic_remote_support_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticRemoteSupportSettings", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_diagnostic_remote_support_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticRemoteSupportSettings/default" + } + + async def _update_diagnostic_remote_support_settings_initial( # pylint: disable=inconsistent-return-statements + self, + device_name: str, + resource_group_name: str, + diagnostic_remote_support_settings: Union[_models.DiagnosticRemoteSupportSettings, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_remote_support_settings, (IO, bytes)): + _content = diagnostic_remote_support_settings + else: + _json = self._serialize.body(diagnostic_remote_support_settings, "DiagnosticRemoteSupportSettings") + + request = build_update_diagnostic_remote_support_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_diagnostic_remote_support_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _update_diagnostic_remote_support_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticRemoteSupportSettings/default" + } + + @overload + async def begin_update_diagnostic_remote_support_settings( + self, + device_name: str, + resource_group_name: str, + diagnostic_remote_support_settings: _models.DiagnosticRemoteSupportSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the diagnostic remote support settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param diagnostic_remote_support_settings: The diagnostic remote support settings. Required. + :type diagnostic_remote_support_settings: + ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticRemoteSupportSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @overload + async def begin_update_diagnostic_remote_support_settings( + self, + device_name: str, + resource_group_name: str, + diagnostic_remote_support_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the diagnostic remote support settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param diagnostic_remote_support_settings: The diagnostic remote support settings. Required. + :type diagnostic_remote_support_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_update_diagnostic_remote_support_settings( + self, + device_name: str, + resource_group_name: str, + diagnostic_remote_support_settings: Union[_models.DiagnosticRemoteSupportSettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the diagnostic remote support settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param diagnostic_remote_support_settings: The diagnostic remote support settings. Is either a + model type or a IO type. Required. + :type diagnostic_remote_support_settings: + ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticRemoteSupportSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_diagnostic_remote_support_settings_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_name, + diagnostic_remote_support_settings=diagnostic_remote_support_settings, + 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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_update_diagnostic_remote_support_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticRemoteSupportSettings/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_jobs_operations.py new file mode 100644 index 000000000000..8dd5f82482b8 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_jobs_operations.py @@ -0,0 +1,121 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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._jobs_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`jobs` 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: + """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. + + Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The job name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Job or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Job", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_monitoring_config_operations.py new file mode 100644 index 000000000000..6f12e1025d85 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_monitoring_config_operations.py @@ -0,0 +1,588 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._monitoring_config_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` 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 + def list( + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MonitoringMetricConfiguration"]: + """Lists metric configurations in a role. + + Lists metric configurations in a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :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 MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + + @distributed_trace_async + async def get( + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: + """Gets a metric configuration of a role. + + Gets a metric configuration of a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringMetricConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + async def _create_or_update_initial( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + monitoring_metric_configuration=monitoring_metric_configuration, + 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("MonitoringMetricConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """deletes a new metric configuration for a role. + + deletes a new metric configuration for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_nodes_operations.py new file mode 100644 index 000000000000..046de870727e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_nodes_operations.py @@ -0,0 +1,148 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._nodes_operations import build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`nodes` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Node"]: + """Gets all the nodes currently configured under this Data Box Edge device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Node or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NodeList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_operations.py new file mode 100644 index 000000000000..2e9f671a5e57 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_operations.py @@ -0,0 +1,139 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations` 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 + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """List all the supported operations. + + List all the supported operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_operations_status_operations.py new file mode 100644 index 000000000000..bfcc8b2779ac --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_operations_status_operations.py @@ -0,0 +1,121 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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._operations_status_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`operations_status` 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: + """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. + + Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The job name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Job or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Job", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_orders_operations.py new file mode 100644 index 000000000000..3c606b19c619 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_orders_operations.py @@ -0,0 +1,610 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._orders_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_list_dc_access_code_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`orders` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Order"]: + """Lists all the orders related to a Data Box Edge/Data Box Gateway device. + + Lists all the orders related to a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Order or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OrderList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: + """Gets a specific order by name. + + Gets a specific order by name. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Order or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Order + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Order", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _create_or_update_initial( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Order", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: ~azure.mgmt.databoxedge.v2021_02_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2021_02_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + resource_group_name=resource_group_name, + order=order, + 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("Order", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the order related to the device. + + Deletes the order related to the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace_async + async def list_dc_access_code( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DCAccessCode: + """Gets the DCAccess Code. + + Gets the DCAccess Code. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DCAccessCode or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DCAccessCode + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DCAccessCode", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_roles_operations.py new file mode 100644 index 000000000000..072453a0f431 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_roles_operations.py @@ -0,0 +1,551 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._roles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`roles` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Role"]: + """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Role or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: + """Gets a specific role by name. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Role or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Role + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Role", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _create_or_update_initial( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Role", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: ~azure.mgmt.databoxedge.v2021_02_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2021_02_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + role=role, + 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("Role", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the role on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_shares_operations.py new file mode 100644 index 000000000000..95c7e85b4b40 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_shares_operations.py @@ -0,0 +1,679 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._shares_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`shares` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Share"]: + """Lists all the shares in a Data Box Edge/Data Box Gateway device. + + Lists all the shares in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Share or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ShareList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: + """Gets a share by name. + + Gets a share by name. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Share or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Share + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Share", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _create_or_update_initial( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Share", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: ~azure.mgmt.databoxedge.v2021_02_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2021_02_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + share=share, + 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("Share", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the share on the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + + @distributed_trace_async + async def begin_refresh( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refreshes the share metadata with the data from the cloud. + + Refreshes the share metadata with the data from the cloud. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._refresh_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_storage_account_credentials_operations.py new file mode 100644 index 000000000000..50f249e914c8 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_storage_account_credentials_operations.py @@ -0,0 +1,575 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._storage_account_credentials_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountCredential"]: + """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. + + Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace_async + async def get( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: + """Gets the properties of the specified storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountCredential or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _create_or_update_initial( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + storage_account_credential=storage_account_credential, + 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("StorageAccountCredential", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_storage_accounts_operations.py new file mode 100644 index 000000000000..8abec7fc320d --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_storage_accounts_operations.py @@ -0,0 +1,580 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._storage_accounts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: + """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. + + Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + + @distributed_trace_async + async def get( + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: + """Gets a StorageAccount by name. + + Gets a StorageAccount by name. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The storage account name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + async def _create_or_update_initial( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + storage_account=storage_account, + 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("StorageAccount", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_support_packages_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_support_packages_operations.py new file mode 100644 index 000000000000..785db67d4327 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_support_packages_operations.py @@ -0,0 +1,274 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._support_packages_operations import build_trigger_support_package_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SupportPackagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`support_packages` 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") + + async def _trigger_support_package_initial( # pylint: disable=inconsistent-return-statements + self, + device_name: str, + resource_group_name: str, + trigger_support_package_request: Union[_models.TriggerSupportPackageRequest, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger_support_package_request, (IO, bytes)): + _content = trigger_support_package_request + else: + _json = self._serialize.body(trigger_support_package_request, "TriggerSupportPackageRequest") + + request = build_trigger_support_package_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._trigger_support_package_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _trigger_support_package_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggerSupportPackage" + } + + @overload + async def begin_trigger_support_package( + self, + device_name: str, + resource_group_name: str, + trigger_support_package_request: _models.TriggerSupportPackageRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Triggers support package on the device. + + Triggers support package on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger_support_package_request: The trigger support package request object. Required. + :type trigger_support_package_request: + ~azure.mgmt.databoxedge.v2021_02_01.models.TriggerSupportPackageRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @overload + async def begin_trigger_support_package( + self, + device_name: str, + resource_group_name: str, + trigger_support_package_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Triggers support package on the device. + + Triggers support package on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger_support_package_request: The trigger support package request object. Required. + :type trigger_support_package_request: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_trigger_support_package( + self, + device_name: str, + resource_group_name: str, + trigger_support_package_request: Union[_models.TriggerSupportPackageRequest, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Triggers support package on the device. + + Triggers support package on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger_support_package_request: The trigger support package request object. Is either a + model type or a IO type. Required. + :type trigger_support_package_request: + ~azure.mgmt.databoxedge.v2021_02_01.models.TriggerSupportPackageRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._trigger_support_package_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_name, + trigger_support_package_request=trigger_support_package_request, + 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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_trigger_support_package.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggerSupportPackage" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_triggers_operations.py new file mode 100644 index 000000000000..95a7cea66cfa --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_triggers_operations.py @@ -0,0 +1,558 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._triggers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`triggers` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Trigger"]: + """Lists all the triggers configured in the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context + tag property. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TriggerList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: + """Get a specific trigger by name. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Trigger or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Trigger + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Trigger", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _create_or_update_initial( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Trigger", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: ~azure.mgmt.databoxedge.v2021_02_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2021_02_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + trigger=trigger, + 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("Trigger", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the trigger on the gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_users_operations.py new file mode 100644 index 000000000000..88dc62c733e4 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/aio/operations/_users_operations.py @@ -0,0 +1,558 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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._users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.aio.DataBoxEdgeManagementClient`'s + :attr:`users` 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 + def list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.User"]: + """Gets all the users registered on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param filter: Specify $filter='Type eq :code:``' to filter on user type property. + Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either User or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UserList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: + """Gets the properties of the specified user. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: User or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.User + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("User", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _create_or_update_initial( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("User", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: ~azure.mgmt.databoxedge.v2021_02_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2021_02_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + user=user, + 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("User", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @distributed_trace_async + async def begin_delete( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the user on a databox edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/__init__.py new file mode 100644 index 000000000000..311fc9d66d30 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/__init__.py @@ -0,0 +1,393 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ARMBaseModel +from ._models_py3 import Addon +from ._models_py3 import AddonList +from ._models_py3 import Address +from ._models_py3 import Alert +from ._models_py3 import AlertErrorDetails +from ._models_py3 import AlertList +from ._models_py3 import ArcAddon +from ._models_py3 import AsymmetricEncryptedSecret +from ._models_py3 import Authentication +from ._models_py3 import AzureContainerInfo +from ._models_py3 import BandwidthSchedule +from ._models_py3 import BandwidthSchedulesList +from ._models_py3 import ClientAccessRight +from ._models_py3 import CloudEdgeManagementRole +from ._models_py3 import CloudErrorBody +from ._models_py3 import CniConfig +from ._models_py3 import ComputeResource +from ._models_py3 import ContactDetails +from ._models_py3 import Container +from ._models_py3 import ContainerList +from ._models_py3 import DCAccessCode +from ._models_py3 import DataBoxEdgeDevice +from ._models_py3 import DataBoxEdgeDeviceExtendedInfo +from ._models_py3 import DataBoxEdgeDeviceExtendedInfoPatch +from ._models_py3 import DataBoxEdgeDeviceList +from ._models_py3 import DataBoxEdgeDevicePatch +from ._models_py3 import DataBoxEdgeMoveRequest +from ._models_py3 import DataBoxEdgeSku +from ._models_py3 import DataBoxEdgeSkuList +from ._models_py3 import DataResidency +from ._models_py3 import DiagnosticProactiveLogCollectionSettings +from ._models_py3 import DiagnosticRemoteSupportSettings +from ._models_py3 import EdgeProfile +from ._models_py3 import EdgeProfilePatch +from ._models_py3 import EdgeProfileSubscription +from ._models_py3 import EdgeProfileSubscriptionPatch +from ._models_py3 import EtcdInfo +from ._models_py3 import FileEventTrigger +from ._models_py3 import FileSourceInfo +from ._models_py3 import GenerateCertResponse +from ._models_py3 import ImageRepositoryCredential +from ._models_py3 import IoTAddon +from ._models_py3 import IoTDeviceInfo +from ._models_py3 import IoTEdgeAgentInfo +from ._models_py3 import IoTRole +from ._models_py3 import Ipv4Config +from ._models_py3 import Ipv6Config +from ._models_py3 import Job +from ._models_py3 import JobErrorDetails +from ._models_py3 import JobErrorItem +from ._models_py3 import KubernetesClusterInfo +from ._models_py3 import KubernetesIPConfiguration +from ._models_py3 import KubernetesRole +from ._models_py3 import KubernetesRoleCompute +from ._models_py3 import KubernetesRoleNetwork +from ._models_py3 import KubernetesRoleResources +from ._models_py3 import KubernetesRoleStorage +from ._models_py3 import KubernetesRoleStorageClassInfo +from ._models_py3 import LoadBalancerConfig +from ._models_py3 import MECRole +from ._models_py3 import MetricConfiguration +from ._models_py3 import MetricCounter +from ._models_py3 import MetricCounterSet +from ._models_py3 import MetricDimension +from ._models_py3 import MetricDimensionV1 +from ._models_py3 import MetricSpecificationV1 +from ._models_py3 import MonitoringMetricConfiguration +from ._models_py3 import MonitoringMetricConfigurationList +from ._models_py3 import MountPointMap +from ._models_py3 import NetworkAdapter +from ._models_py3 import NetworkAdapterPosition +from ._models_py3 import NetworkSettings +from ._models_py3 import Node +from ._models_py3 import NodeInfo +from ._models_py3 import NodeList +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import Order +from ._models_py3 import OrderList +from ._models_py3 import OrderStatus +from ._models_py3 import PeriodicTimerEventTrigger +from ._models_py3 import PeriodicTimerSourceInfo +from ._models_py3 import RefreshDetails +from ._models_py3 import RemoteSupportSettings +from ._models_py3 import ResourceIdentity +from ._models_py3 import ResourceMoveDetails +from ._models_py3 import ResourceTypeSku +from ._models_py3 import Role +from ._models_py3 import RoleList +from ._models_py3 import RoleSinkInfo +from ._models_py3 import Secret +from ._models_py3 import SecuritySettings +from ._models_py3 import ServiceSpecification +from ._models_py3 import Share +from ._models_py3 import ShareAccessRight +from ._models_py3 import ShareList +from ._models_py3 import Sku +from ._models_py3 import SkuCapability +from ._models_py3 import SkuCost +from ._models_py3 import SkuInformation +from ._models_py3 import SkuInformationList +from ._models_py3 import SkuLocationInfo +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCredential +from ._models_py3 import StorageAccountCredentialList +from ._models_py3 import StorageAccountList +from ._models_py3 import SubscriptionRegisteredFeatures +from ._models_py3 import SymmetricKey +from ._models_py3 import SystemData +from ._models_py3 import TrackingInfo +from ._models_py3 import Trigger +from ._models_py3 import TriggerList +from ._models_py3 import TriggerSupportPackageRequest +from ._models_py3 import UpdateDetails +from ._models_py3 import UpdateDownloadProgress +from ._models_py3 import UpdateInstallProgress +from ._models_py3 import UpdateSummary +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UploadCertificateResponse +from ._models_py3 import User +from ._models_py3 import UserAccessRight +from ._models_py3 import UserList + +from ._data_box_edge_management_client_enums import AccessLevel +from ._data_box_edge_management_client_enums import AccountType +from ._data_box_edge_management_client_enums import AddonState +from ._data_box_edge_management_client_enums import AddonType +from ._data_box_edge_management_client_enums import AlertSeverity +from ._data_box_edge_management_client_enums import AuthenticationType +from ._data_box_edge_management_client_enums import AzureContainerDataFormat +from ._data_box_edge_management_client_enums import ClientPermissionType +from ._data_box_edge_management_client_enums import ContainerStatus +from ._data_box_edge_management_client_enums import CreatedByType +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceKind +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceStatus +from ._data_box_edge_management_client_enums import DataPolicy +from ._data_box_edge_management_client_enums import DataResidencyType +from ._data_box_edge_management_client_enums import DayOfWeek +from ._data_box_edge_management_client_enums import DeviceType +from ._data_box_edge_management_client_enums import DownloadPhase +from ._data_box_edge_management_client_enums import EncryptionAlgorithm +from ._data_box_edge_management_client_enums import HostPlatformType +from ._data_box_edge_management_client_enums import InstallRebootBehavior +from ._data_box_edge_management_client_enums import InstallationImpact +from ._data_box_edge_management_client_enums import JobStatus +from ._data_box_edge_management_client_enums import JobType +from ._data_box_edge_management_client_enums import KeyVaultSyncStatus +from ._data_box_edge_management_client_enums import KubernetesNodeType +from ._data_box_edge_management_client_enums import KubernetesState +from ._data_box_edge_management_client_enums import MetricAggregationType +from ._data_box_edge_management_client_enums import MetricCategory +from ._data_box_edge_management_client_enums import MetricUnit +from ._data_box_edge_management_client_enums import MonitoringStatus +from ._data_box_edge_management_client_enums import MountType +from ._data_box_edge_management_client_enums import MsiIdentityType +from ._data_box_edge_management_client_enums import NetworkAdapterDHCPStatus +from ._data_box_edge_management_client_enums import NetworkAdapterRDMAStatus +from ._data_box_edge_management_client_enums import NetworkAdapterStatus +from ._data_box_edge_management_client_enums import NetworkGroup +from ._data_box_edge_management_client_enums import NodeStatus +from ._data_box_edge_management_client_enums import OrderState +from ._data_box_edge_management_client_enums import PlatformType +from ._data_box_edge_management_client_enums import PosixComplianceStatus +from ._data_box_edge_management_client_enums import ProactiveDiagnosticsConsent +from ._data_box_edge_management_client_enums import RemoteApplicationType +from ._data_box_edge_management_client_enums import ResourceMoveStatus +from ._data_box_edge_management_client_enums import RoleStatus +from ._data_box_edge_management_client_enums import RoleTypes +from ._data_box_edge_management_client_enums import SSLStatus +from ._data_box_edge_management_client_enums import ShareAccessProtocol +from ._data_box_edge_management_client_enums import ShareAccessType +from ._data_box_edge_management_client_enums import ShareStatus +from ._data_box_edge_management_client_enums import ShipmentType +from ._data_box_edge_management_client_enums import SkuAvailability +from ._data_box_edge_management_client_enums import SkuName +from ._data_box_edge_management_client_enums import SkuSignupOption +from ._data_box_edge_management_client_enums import SkuTier +from ._data_box_edge_management_client_enums import SkuVersion +from ._data_box_edge_management_client_enums import StorageAccountStatus +from ._data_box_edge_management_client_enums import SubscriptionState +from ._data_box_edge_management_client_enums import TimeGrain +from ._data_box_edge_management_client_enums import TriggerEventType +from ._data_box_edge_management_client_enums import UpdateOperation +from ._data_box_edge_management_client_enums import UpdateOperationStage +from ._data_box_edge_management_client_enums import UpdateStatus +from ._data_box_edge_management_client_enums import UpdateType +from ._data_box_edge_management_client_enums import UserType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ARMBaseModel", + "Addon", + "AddonList", + "Address", + "Alert", + "AlertErrorDetails", + "AlertList", + "ArcAddon", + "AsymmetricEncryptedSecret", + "Authentication", + "AzureContainerInfo", + "BandwidthSchedule", + "BandwidthSchedulesList", + "ClientAccessRight", + "CloudEdgeManagementRole", + "CloudErrorBody", + "CniConfig", + "ComputeResource", + "ContactDetails", + "Container", + "ContainerList", + "DCAccessCode", + "DataBoxEdgeDevice", + "DataBoxEdgeDeviceExtendedInfo", + "DataBoxEdgeDeviceExtendedInfoPatch", + "DataBoxEdgeDeviceList", + "DataBoxEdgeDevicePatch", + "DataBoxEdgeMoveRequest", + "DataBoxEdgeSku", + "DataBoxEdgeSkuList", + "DataResidency", + "DiagnosticProactiveLogCollectionSettings", + "DiagnosticRemoteSupportSettings", + "EdgeProfile", + "EdgeProfilePatch", + "EdgeProfileSubscription", + "EdgeProfileSubscriptionPatch", + "EtcdInfo", + "FileEventTrigger", + "FileSourceInfo", + "GenerateCertResponse", + "ImageRepositoryCredential", + "IoTAddon", + "IoTDeviceInfo", + "IoTEdgeAgentInfo", + "IoTRole", + "Ipv4Config", + "Ipv6Config", + "Job", + "JobErrorDetails", + "JobErrorItem", + "KubernetesClusterInfo", + "KubernetesIPConfiguration", + "KubernetesRole", + "KubernetesRoleCompute", + "KubernetesRoleNetwork", + "KubernetesRoleResources", + "KubernetesRoleStorage", + "KubernetesRoleStorageClassInfo", + "LoadBalancerConfig", + "MECRole", + "MetricConfiguration", + "MetricCounter", + "MetricCounterSet", + "MetricDimension", + "MetricDimensionV1", + "MetricSpecificationV1", + "MonitoringMetricConfiguration", + "MonitoringMetricConfigurationList", + "MountPointMap", + "NetworkAdapter", + "NetworkAdapterPosition", + "NetworkSettings", + "Node", + "NodeInfo", + "NodeList", + "Operation", + "OperationDisplay", + "OperationsList", + "Order", + "OrderList", + "OrderStatus", + "PeriodicTimerEventTrigger", + "PeriodicTimerSourceInfo", + "RefreshDetails", + "RemoteSupportSettings", + "ResourceIdentity", + "ResourceMoveDetails", + "ResourceTypeSku", + "Role", + "RoleList", + "RoleSinkInfo", + "Secret", + "SecuritySettings", + "ServiceSpecification", + "Share", + "ShareAccessRight", + "ShareList", + "Sku", + "SkuCapability", + "SkuCost", + "SkuInformation", + "SkuInformationList", + "SkuLocationInfo", + "StorageAccount", + "StorageAccountCredential", + "StorageAccountCredentialList", + "StorageAccountList", + "SubscriptionRegisteredFeatures", + "SymmetricKey", + "SystemData", + "TrackingInfo", + "Trigger", + "TriggerList", + "TriggerSupportPackageRequest", + "UpdateDetails", + "UpdateDownloadProgress", + "UpdateInstallProgress", + "UpdateSummary", + "UploadCertificateRequest", + "UploadCertificateResponse", + "User", + "UserAccessRight", + "UserList", + "AccessLevel", + "AccountType", + "AddonState", + "AddonType", + "AlertSeverity", + "AuthenticationType", + "AzureContainerDataFormat", + "ClientPermissionType", + "ContainerStatus", + "CreatedByType", + "DataBoxEdgeDeviceKind", + "DataBoxEdgeDeviceStatus", + "DataPolicy", + "DataResidencyType", + "DayOfWeek", + "DeviceType", + "DownloadPhase", + "EncryptionAlgorithm", + "HostPlatformType", + "InstallRebootBehavior", + "InstallationImpact", + "JobStatus", + "JobType", + "KeyVaultSyncStatus", + "KubernetesNodeType", + "KubernetesState", + "MetricAggregationType", + "MetricCategory", + "MetricUnit", + "MonitoringStatus", + "MountType", + "MsiIdentityType", + "NetworkAdapterDHCPStatus", + "NetworkAdapterRDMAStatus", + "NetworkAdapterStatus", + "NetworkGroup", + "NodeStatus", + "OrderState", + "PlatformType", + "PosixComplianceStatus", + "ProactiveDiagnosticsConsent", + "RemoteApplicationType", + "ResourceMoveStatus", + "RoleStatus", + "RoleTypes", + "SSLStatus", + "ShareAccessProtocol", + "ShareAccessType", + "ShareStatus", + "ShipmentType", + "SkuAvailability", + "SkuName", + "SkuSignupOption", + "SkuTier", + "SkuVersion", + "StorageAccountStatus", + "SubscriptionState", + "TimeGrain", + "TriggerEventType", + "UpdateOperation", + "UpdateOperationStage", + "UpdateStatus", + "UpdateType", + "UserType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_data_box_edge_management_client_enums.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_data_box_edge_management_client_enums.py new file mode 100644 index 000000000000..9067afa140b7 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_data_box_edge_management_client_enums.py @@ -0,0 +1,614 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access level allowed for this remote application type.""" + + NONE = "None" + READ_ONLY = "ReadOnly" + READ_WRITE = "ReadWrite" + FULL_ACCESS = "FullAccess" + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of storage accessed on the storage account.""" + + GENERAL_PURPOSE_STORAGE = "GeneralPurposeStorage" + BLOB_STORAGE = "BlobStorage" + + +class AddonState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon Provisioning State.""" + + INVALID = "Invalid" + CREATING = "Creating" + CREATED = "Created" + UPDATING = "Updating" + RECONFIGURING = "Reconfiguring" + FAILED = "Failed" + DELETING = "Deleting" + + +class AddonType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon type.""" + + IOT_EDGE = "IotEdge" + ARC_FOR_KUBERNETES = "ArcForKubernetes" + + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert.""" + + INFORMATIONAL = "Informational" + WARNING = "Warning" + CRITICAL = "Critical" + + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication type.""" + + INVALID = "Invalid" + AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" + + +class AzureContainerDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage format used for the file represented by the share.""" + + BLOCK_BLOB = "BlockBlob" + PAGE_BLOB = "PageBlob" + AZURE_FILE = "AzureFile" + + +class ClientPermissionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed for the client.""" + + NO_ACCESS = "NoAccess" + READ_ONLY = "ReadOnly" + READ_WRITE = "ReadWrite" + + +class ContainerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the container.""" + + OK = "OK" + OFFLINE = "Offline" + UNKNOWN = "Unknown" + UPDATING = "Updating" + NEEDS_ATTENTION = "NeedsAttention" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DataBoxEdgeDeviceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of the device.""" + + AZURE_DATA_BOX_GATEWAY = "AzureDataBoxGateway" + AZURE_STACK_EDGE = "AzureStackEdge" + AZURE_STACK_HUB = "AzureStackHub" + AZURE_MODULAR_DATA_CENTRE = "AzureModularDataCentre" + + +class DataBoxEdgeDeviceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the Data Box Edge/Gateway device.""" + + READY_TO_SETUP = "ReadyToSetup" + ONLINE = "Online" + OFFLINE = "Offline" + NEEDS_ATTENTION = "NeedsAttention" + DISCONNECTED = "Disconnected" + PARTIALLY_DISCONNECTED = "PartiallyDisconnected" + MAINTENANCE = "Maintenance" + + +class DataPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data policy of the share.""" + + CLOUD = "Cloud" + LOCAL = "Local" + + +class DataResidencyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DataResidencyType enum.""" + + GEO_ZONE_REPLICATION = "GeoZoneReplication" + ZONE_REPLICATION = "ZoneReplication" + + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" + + SUNDAY = "Sunday" + MONDAY = "Monday" + TUESDAY = "Tuesday" + WEDNESDAY = "Wednesday" + THURSDAY = "Thursday" + FRIDAY = "Friday" + SATURDAY = "Saturday" + + +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the Data Box Edge/Gateway device.""" + + DATA_BOX_EDGE_DEVICE = "DataBoxEdgeDevice" + + +class DownloadPhase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The download phase.""" + + UNKNOWN = "Unknown" + INITIALIZING = "Initializing" + DOWNLOADING = "Downloading" + VERIFYING = "Verifying" + + +class EncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The algorithm used to encrypt "Value".""" + + NONE = "None" + AES256 = "AES256" + RSAES_PKCS1_V1_5 = "RSAES_PKCS1_v_1_5" + + +class HostPlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Platform where the runtime is hosted.""" + + KUBERNETES_CLUSTER = "KubernetesCluster" + LINUX_VM = "LinuxVM" + + +class InstallationImpact(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Impact of Installing an updateType.""" + + NONE = "None" + DEVICE_REBOOTED = "DeviceRebooted" + KUBERNETES_WORKLOADS_DOWN = "KubernetesWorkloadsDown" + + +class InstallRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if updates are available and at least one of the updates needs a reboot.""" + + NEVER_REBOOTS = "NeverReboots" + REQUIRES_REBOOT = "RequiresReboot" + REQUEST_REBOOT = "RequestReboot" + + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the job.""" + + INVALID = "Invalid" + RUNNING = "Running" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + PAUSED = "Paused" + SCHEDULED = "Scheduled" + + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" + + INVALID = "Invalid" + SCAN_FOR_UPDATES = "ScanForUpdates" + DOWNLOAD_UPDATES = "DownloadUpdates" + INSTALL_UPDATES = "InstallUpdates" + REFRESH_SHARE = "RefreshShare" + REFRESH_CONTAINER = "RefreshContainer" + BACKUP = "Backup" + RESTORE = "Restore" + TRIGGER_SUPPORT_PACKAGE = "TriggerSupportPackage" + + +class KeyVaultSyncStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """For changing or to initiate the resync to key-vault set the status to KeyVaultSyncPending, rest + of the status will not be applicable. + """ + + KEY_VAULT_SYNCED = "KeyVaultSynced" + KEY_VAULT_SYNC_FAILED = "KeyVaultSyncFailed" + KEY_VAULT_NOT_CONFIGURED = "KeyVaultNotConfigured" + KEY_VAULT_SYNC_PENDING = "KeyVaultSyncPending" + KEY_VAULT_SYNCING = "KeyVaultSyncing" + KEY_VAULT_NOT_SYNCED = "KeyVaultNotSynced" + + +class KubernetesNodeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Node type - Master/Worker.""" + + INVALID = "Invalid" + MASTER = "Master" + WORKER = "Worker" + + +class KubernetesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of Kubernetes deployment.""" + + INVALID = "Invalid" + CREATING = "Creating" + CREATED = "Created" + UPDATING = "Updating" + RECONFIGURING = "Reconfiguring" + FAILED = "Failed" + DELETING = "Deleting" + + +class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric aggregation type.""" + + NOT_SPECIFIED = "NotSpecified" + NONE = "None" + AVERAGE = "Average" + MINIMUM = "Minimum" + MAXIMUM = "Maximum" + TOTAL = "Total" + COUNT = "Count" + + +class MetricCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric category.""" + + CAPACITY = "Capacity" + TRANSACTION = "Transaction" + + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric units.""" + + NOT_SPECIFIED = "NotSpecified" + PERCENT = "Percent" + COUNT = "Count" + SECONDS = "Seconds" + MILLISECONDS = "Milliseconds" + BYTES = "Bytes" + BYTES_PER_SECOND = "BytesPerSecond" + COUNT_PER_SECOND = "CountPerSecond" + + +class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current monitoring status of the share.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class MountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Mounting type.""" + + VOLUME = "Volume" + HOST_PATH = "HostPath" + + +class MsiIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Identity type.""" + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + + +class NetworkAdapterDHCPStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter has DHCP enabled.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class NetworkAdapterRDMAStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is RDMA capable.""" + + INCAPABLE = "Incapable" + CAPABLE = "Capable" + + +class NetworkAdapterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is valid.""" + + INACTIVE = "Inactive" + ACTIVE = "Active" + + +class NetworkGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network group.""" + + NONE = "None" + NON_RDMA = "NonRDMA" + RDMA = "RDMA" + + +class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the individual node.""" + + UNKNOWN = "Unknown" + UP = "Up" + DOWN = "Down" + REBOOTING = "Rebooting" + SHUTTING_DOWN = "ShuttingDown" + + +class OrderState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the order as per the allowed status types.""" + + UNTRACKED = "Untracked" + AWAITING_FULFILLMENT = "AwaitingFulfillment" + AWAITING_PREPARATION = "AwaitingPreparation" + AWAITING_SHIPMENT = "AwaitingShipment" + SHIPPED = "Shipped" + ARRIVING = "Arriving" + DELIVERED = "Delivered" + REPLACEMENT_REQUESTED = "ReplacementRequested" + LOST_DEVICE = "LostDevice" + DECLINED = "Declined" + RETURN_INITIATED = "ReturnInitiated" + AWAITING_RETURN_SHIPMENT = "AwaitingReturnShipment" + SHIPPED_BACK = "ShippedBack" + COLLECTED_AT_MICROSOFT = "CollectedAtMicrosoft" + AWAITING_PICKUP = "AwaitingPickup" + PICKUP_COMPLETED = "PickupCompleted" + AWAITING_DROP = "AwaitingDrop" + + +class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host OS supported by the Arc addon.""" + + WINDOWS = "Windows" + LINUX = "Linux" + + +class PosixComplianceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """If provisioned storage is posix compliant.""" + + INVALID = "Invalid" + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ProactiveDiagnosticsConsent(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Proactive diagnostic collection consent flag.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class RemoteApplicationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Remote application type.""" + + POWERSHELL = "Powershell" + WAC = "WAC" + LOCAL_UI = "LocalUI" + ALL_APPLICATIONS = "AllApplications" + + +class ResourceMoveStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Denotes whether move operation is in progress.""" + + NONE = "None" + RESOURCE_MOVE_IN_PROGRESS = "ResourceMoveInProgress" + RESOURCE_MOVE_FAILED = "ResourceMoveFailed" + + +class RoleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Local Edge Management Status.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class RoleTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleTypes.""" + + IOT = "IOT" + ASA = "ASA" + FUNCTIONS = "Functions" + COGNITIVE = "Cognitive" + MEC = "MEC" + CLOUD_EDGE_MANAGEMENT = "CloudEdgeManagement" + KUBERNETES = "Kubernetes" + + +class ShareAccessProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access protocol to be used by the share.""" + + SMB = "SMB" + NFS = "NFS" + + +class ShareAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed on the share for this user.""" + + CHANGE = "Change" + READ = "Read" + CUSTOM = "Custom" + + +class ShareStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the share.""" + + OFFLINE = "Offline" + UNKNOWN = "Unknown" + OK = "OK" + UPDATING = "Updating" + NEEDS_ATTENTION = "NeedsAttention" + + +class ShipmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ShipmentType.""" + + NOT_APPLICABLE = "NotApplicable" + SHIPPED_TO_CUSTOMER = "ShippedToCustomer" + SELF_PICKUP = "SelfPickup" + + +class SkuAvailability(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Links to the next set of results.""" + + AVAILABLE = "Available" + UNAVAILABLE = "Unavailable" + + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku name.""" + + GATEWAY = "Gateway" + EDGE = "Edge" + TEA1_NODE = "TEA_1Node" + TEA1_NODE_UPS = "TEA_1Node_UPS" + TEA1_NODE_HEATER = "TEA_1Node_Heater" + TEA1_NODE_UPS_HEATER = "TEA_1Node_UPS_Heater" + TEA4_NODE_HEATER = "TEA_4Node_Heater" + TEA4_NODE_UPS_HEATER = "TEA_4Node_UPS_Heater" + TMA = "TMA" + TDC = "TDC" + TCA_SMALL = "TCA_Small" + GPU = "GPU" + TCA_LARGE = "TCA_Large" + EDGE_P_BASE = "EdgeP_Base" + EDGE_P_HIGH = "EdgeP_High" + EDGE_PR_BASE = "EdgePR_Base" + EDGE_PR_BASE_UPS = "EdgePR_Base_UPS" + EP2_64_1_VPU_W = "EP2_64_1VPU_W" + EP2_128_1_T4_MX1_W = "EP2_128_1T4_Mx1_W" + EP2_256_2_T4_W = "EP2_256_2T4_W" + EDGE_MR_MINI = "EdgeMR_Mini" + RCA_SMALL = "RCA_Small" + RCA_LARGE = "RCA_Large" + RDC = "RDC" + MANAGEMENT = "Management" + + +class SkuSignupOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sku can be signed up by customer or not.""" + + NONE = "None" + AVAILABLE = "Available" + + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku tier.""" + + STANDARD = "Standard" + + +class SkuVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Availability of the Sku as preview/stable.""" + + STABLE = "Stable" + PREVIEW = "Preview" + + +class SSLStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Signifies whether SSL needs to be enabled or not.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class StorageAccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the storage account.""" + + OK = "OK" + OFFLINE = "Offline" + UNKNOWN = "Unknown" + UPDATING = "Updating" + NEEDS_ATTENTION = "NeedsAttention" + + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SubscriptionState.""" + + REGISTERED = "Registered" + WARNED = "Warned" + SUSPENDED = "Suspended" + DELETED = "Deleted" + UNREGISTERED = "Unregistered" + + +class TimeGrain(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TimeGrain.""" + + PT1_M = "PT1M" + PT5_M = "PT5M" + PT15_M = "PT15M" + PT30_M = "PT30M" + PT1_H = "PT1H" + PT6_H = "PT6H" + PT12_H = "PT12H" + PT1_D = "PT1D" + + +class TriggerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trigger Kind.""" + + FILE_EVENT = "FileEvent" + PERIODIC_TIMER_EVENT = "PeriodicTimerEvent" + + +class UpdateOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current update operation.""" + + NONE = "None" + SCAN = "Scan" + DOWNLOAD = "Download" + INSTALL = "Install" + + +class UpdateOperationStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current stage of the update operation.""" + + UNKNOWN = "Unknown" + INITIAL = "Initial" + SCAN_STARTED = "ScanStarted" + SCAN_COMPLETE = "ScanComplete" + SCAN_FAILED = "ScanFailed" + DOWNLOAD_STARTED = "DownloadStarted" + DOWNLOAD_COMPLETE = "DownloadComplete" + DOWNLOAD_FAILED = "DownloadFailed" + INSTALL_STARTED = "InstallStarted" + INSTALL_COMPLETE = "InstallComplete" + INSTALL_FAILED = "InstallFailed" + REBOOT_INITIATED = "RebootInitiated" + SUCCESS = "Success" + FAILURE = "Failure" + RESCAN_STARTED = "RescanStarted" + RESCAN_COMPLETE = "RescanComplete" + RESCAN_FAILED = "RescanFailed" + + +class UpdateStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the update.""" + + DOWNLOAD_PENDING = "DownloadPending" + DOWNLOAD_STARTED = "DownloadStarted" + DOWNLOAD_COMPLETED = "DownloadCompleted" + INSTALL_STARTED = "InstallStarted" + INSTALL_COMPLETED = "InstallCompleted" + + +class UpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the Update.""" + + SOFTWARE = "Software" + KUBERNETES = "Kubernetes" + FIRMWARE = "Firmware" + + +class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the user.""" + + SHARE = "Share" + LOCAL_MANAGEMENT = "LocalManagement" + ARM = "ARM" diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_models_py3.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_models_py3.py new file mode 100644 index 000000000000..4e7efdb391b0 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_models_py3.py @@ -0,0 +1,6280 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class ARMBaseModel(_serialization.Model): + """Represents the base class for all object models. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Addon(ARMBaseModel): + """Role Addon. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ArcAddon, IoTAddon + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AddonType + :ivar system_data: Addon type. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + _subtype_map = {"kind": {"ArcForKubernetes": "ArcAddon", "IotEdge": "IoTAddon"}} + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None + self.system_data = None + + +class AddonList(_serialization.Model): + """Collection of all the Role addon on the Azure Stack Edge device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The Value. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Addon] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Addon]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class Address(_serialization.Model): + """The shipping address of the customer. + + All required parameters must be populated in order to send to Azure. + + :ivar address_line1: The address line1. + :vartype address_line1: str + :ivar address_line2: The address line2. + :vartype address_line2: str + :ivar address_line3: The address line3. + :vartype address_line3: str + :ivar postal_code: The postal code. + :vartype postal_code: str + :ivar city: The city name. + :vartype city: str + :ivar state: The state name. + :vartype state: str + :ivar country: The country name. Required. + :vartype country: str + """ + + _validation = { + "country": {"required": True}, + } + + _attribute_map = { + "address_line1": {"key": "addressLine1", "type": "str"}, + "address_line2": {"key": "addressLine2", "type": "str"}, + "address_line3": {"key": "addressLine3", "type": "str"}, + "postal_code": {"key": "postalCode", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "country": {"key": "country", "type": "str"}, + } + + def __init__( + self, + *, + country: str, + address_line1: Optional[str] = None, + address_line2: Optional[str] = None, + address_line3: Optional[str] = None, + postal_code: Optional[str] = None, + city: Optional[str] = None, + state: Optional[str] = None, + **kwargs + ): + """ + :keyword address_line1: The address line1. + :paramtype address_line1: str + :keyword address_line2: The address line2. + :paramtype address_line2: str + :keyword address_line3: The address line3. + :paramtype address_line3: str + :keyword postal_code: The postal code. + :paramtype postal_code: str + :keyword city: The city name. + :paramtype city: str + :keyword state: The state name. + :paramtype state: str + :keyword country: The country name. Required. + :paramtype country: str + """ + super().__init__(**kwargs) + self.address_line1 = address_line1 + self.address_line2 = address_line2 + self.address_line3 = address_line3 + self.postal_code = postal_code + self.city = city + self.state = state + self.country = country + + +class Alert(ARMBaseModel): # pylint: disable=too-many-instance-attributes + """Alert on the data box edge/gateway device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: Alert generated in the resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar title: Alert title. + :vartype title: str + :ivar alert_type: Alert type. + :vartype alert_type: str + :ivar appeared_at_date_time: UTC time when the alert appeared. + :vartype appeared_at_date_time: ~datetime.datetime + :ivar recommendation: Alert recommendation. + :vartype recommendation: str + :ivar severity: Severity of the alert. Known values are: "Informational", "Warning", and + "Critical". + :vartype severity: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AlertSeverity + :ivar error_details: Error details of the alert. + :vartype error_details: ~azure.mgmt.databoxedge.v2021_02_01.models.AlertErrorDetails + :ivar detailed_information: Alert details. + :vartype detailed_information: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "title": {"readonly": True}, + "alert_type": {"readonly": True}, + "appeared_at_date_time": {"readonly": True}, + "recommendation": {"readonly": True}, + "severity": {"readonly": True}, + "error_details": {"readonly": True}, + "detailed_information": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "title": {"key": "properties.title", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "appeared_at_date_time": {"key": "properties.appearedAtDateTime", "type": "iso-8601"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "error_details": {"key": "properties.errorDetails", "type": "AlertErrorDetails"}, + "detailed_information": {"key": "properties.detailedInformation", "type": "{str}"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.system_data = None + self.title = None + self.alert_type = None + self.appeared_at_date_time = None + self.recommendation = None + self.severity = None + self.error_details = None + self.detailed_information = None + + +class AlertErrorDetails(_serialization.Model): + """Error details for the alert. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar error_code: Error code. + :vartype error_code: str + :ivar error_message: Error Message. + :vartype error_message: str + :ivar occurrences: Number of occurrences. + :vartype occurrences: int + """ + + _validation = { + "error_code": {"readonly": True}, + "error_message": {"readonly": True}, + "occurrences": {"readonly": True}, + } + + _attribute_map = { + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "occurrences": {"key": "occurrences", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.error_code = None + self.error_message = None + self.occurrences = None + + +class AlertList(_serialization.Model): + """Collection of alerts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The value. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Alert] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ArcAddon(Addon): # pylint: disable=too-many-instance-attributes + """Arc Addon. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AddonType + :ivar system_data: Addon type. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar subscription_id: Arc resource subscription Id. Required. + :vartype subscription_id: str + :ivar resource_group_name: Arc resource group name. Required. + :vartype resource_group_name: str + :ivar resource_name: Arc resource Name. Required. + :vartype resource_name: str + :ivar resource_location: Arc resource location. Required. + :vartype resource_location: str + :ivar version: Arc resource version. + :vartype version: str + :ivar host_platform: Host OS supported by the Arc addon. Known values are: "Windows" and + "Linux". + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01.models.PlatformType + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". + :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.HostPlatformType + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AddonState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "subscription_id": {"required": True}, + "resource_group_name": {"required": True}, + "resource_name": {"required": True}, + "resource_location": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "subscription_id": {"key": "properties.subscriptionId", "type": "str"}, + "resource_group_name": {"key": "properties.resourceGroupName", "type": "str"}, + "resource_name": {"key": "properties.resourceName", "type": "str"}, + "resource_location": {"key": "properties.resourceLocation", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, *, subscription_id: str, resource_group_name: str, resource_name: str, resource_location: str, **kwargs + ): + """ + :keyword subscription_id: Arc resource subscription Id. Required. + :paramtype subscription_id: str + :keyword resource_group_name: Arc resource group name. Required. + :paramtype resource_group_name: str + :keyword resource_name: Arc resource Name. Required. + :paramtype resource_name: str + :keyword resource_location: Arc resource location. Required. + :paramtype resource_location: str + """ + super().__init__(**kwargs) + self.kind: str = "ArcForKubernetes" + self.subscription_id = subscription_id + self.resource_group_name = resource_group_name + self.resource_name = resource_name + self.resource_location = resource_location + self.version = None + self.host_platform = None + self.host_platform_type = None + self.provisioning_state = None + + +class AsymmetricEncryptedSecret(_serialization.Model): + """Represent the secrets intended for encryption with asymmetric key pair. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The value of the secret. Required. + :vartype value: str + :ivar encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :vartype encryption_cert_thumbprint: str + :ivar encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values are: + "None", "AES256", and "RSAES_PKCS1_v_1_5". + :vartype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.EncryptionAlgorithm + """ + + _validation = { + "value": {"required": True}, + "encryption_algorithm": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "encryption_cert_thumbprint": {"key": "encryptionCertThumbprint", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, + } + + def __init__( + self, + *, + value: str, + encryption_algorithm: Union[str, "_models.EncryptionAlgorithm"], + encryption_cert_thumbprint: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The value of the secret. Required. + :paramtype value: str + :keyword encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :paramtype encryption_cert_thumbprint: str + :keyword encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values + are: "None", "AES256", and "RSAES_PKCS1_v_1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.EncryptionAlgorithm + """ + super().__init__(**kwargs) + self.value = value + self.encryption_cert_thumbprint = encryption_cert_thumbprint + self.encryption_algorithm = encryption_algorithm + + +class Authentication(_serialization.Model): + """Authentication mechanism for IoT devices. + + :ivar symmetric_key: Symmetric key for authentication. + :vartype symmetric_key: ~azure.mgmt.databoxedge.v2021_02_01.models.SymmetricKey + """ + + _attribute_map = { + "symmetric_key": {"key": "symmetricKey", "type": "SymmetricKey"}, + } + + def __init__(self, *, symmetric_key: Optional["_models.SymmetricKey"] = None, **kwargs): + """ + :keyword symmetric_key: Symmetric key for authentication. + :paramtype symmetric_key: ~azure.mgmt.databoxedge.v2021_02_01.models.SymmetricKey + """ + super().__init__(**kwargs) + self.symmetric_key = symmetric_key + + +class AzureContainerInfo(_serialization.Model): + """Azure container mapping of the endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :vartype storage_account_credential_id: str + :ivar container_name: Container name (Based on the data format specified, this represents the + name of Azure Files/Page blob/Block blob). Required. + :vartype container_name: str + :ivar data_format: Storage format used for the file represented by the share. Required. Known + values are: "BlockBlob", "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.AzureContainerDataFormat + """ + + _validation = { + "storage_account_credential_id": {"required": True}, + "container_name": {"required": True}, + "data_format": {"required": True}, + } + + _attribute_map = { + "storage_account_credential_id": {"key": "storageAccountCredentialId", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "data_format": {"key": "dataFormat", "type": "str"}, + } + + def __init__( + self, + *, + storage_account_credential_id: str, + container_name: str, + data_format: Union[str, "_models.AzureContainerDataFormat"], + **kwargs + ): + """ + :keyword storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :paramtype storage_account_credential_id: str + :keyword container_name: Container name (Based on the data format specified, this represents + the name of Azure Files/Page blob/Block blob). Required. + :paramtype container_name: str + :keyword data_format: Storage format used for the file represented by the share. Required. + Known values are: "BlockBlob", "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) + self.storage_account_credential_id = storage_account_credential_id + self.container_name = container_name + self.data_format = data_format + + +class BandwidthSchedule(ARMBaseModel): + """The bandwidth schedule details. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: Bandwidth object related to ASE resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar start: The start time of the schedule in UTC. Required. + :vartype start: str + :ivar stop: The stop time of the schedule in UTC. Required. + :vartype stop: str + :ivar rate_in_mbps: The bandwidth rate in Mbps. Required. + :vartype rate_in_mbps: int + :ivar days: The days of the week when this schedule is applicable. Required. + :vartype days: list[str or ~azure.mgmt.databoxedge.v2021_02_01.models.DayOfWeek] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "start": {"required": True}, + "stop": {"required": True}, + "rate_in_mbps": {"required": True}, + "days": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "start": {"key": "properties.start", "type": "str"}, + "stop": {"key": "properties.stop", "type": "str"}, + "rate_in_mbps": {"key": "properties.rateInMbps", "type": "int"}, + "days": {"key": "properties.days", "type": "[str]"}, + } + + def __init__( + self, *, start: str, stop: str, rate_in_mbps: int, days: List[Union[str, "_models.DayOfWeek"]], **kwargs + ): + """ + :keyword start: The start time of the schedule in UTC. Required. + :paramtype start: str + :keyword stop: The stop time of the schedule in UTC. Required. + :paramtype stop: str + :keyword rate_in_mbps: The bandwidth rate in Mbps. Required. + :paramtype rate_in_mbps: int + :keyword days: The days of the week when this schedule is applicable. Required. + :paramtype days: list[str or ~azure.mgmt.databoxedge.v2021_02_01.models.DayOfWeek] + """ + super().__init__(**kwargs) + self.system_data = None + self.start = start + self.stop = stop + self.rate_in_mbps = rate_in_mbps + self.days = days + + +class BandwidthSchedulesList(_serialization.Model): + """The collection of bandwidth schedules. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of bandwidth schedules. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[BandwidthSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ClientAccessRight(_serialization.Model): + """The mapping between a particular client IP and the type of access client has on the NFS share. + + All required parameters must be populated in order to send to Azure. + + :ivar client: IP of the client. Required. + :vartype client: str + :ivar access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :vartype access_permission: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.ClientPermissionType + """ + + _validation = { + "client": {"required": True}, + "access_permission": {"required": True}, + } + + _attribute_map = { + "client": {"key": "client", "type": "str"}, + "access_permission": {"key": "accessPermission", "type": "str"}, + } + + def __init__(self, *, client: str, access_permission: Union[str, "_models.ClientPermissionType"], **kwargs): + """ + :keyword client: IP of the client. Required. + :paramtype client: str + :keyword access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :paramtype access_permission: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.ClientPermissionType + """ + super().__init__(**kwargs) + self.client = client + self.access_permission = access_permission + + +class Role(ARMBaseModel): + """Compute role. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleTypes + :ivar system_data: Role configured on ASE resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + _subtype_map = { + "kind": { + "CloudEdgeManagement": "CloudEdgeManagementRole", + "IOT": "IoTRole", + "Kubernetes": "KubernetesRole", + "MEC": "MECRole", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None + self.system_data = None + + +class CloudEdgeManagementRole(Role): + """The preview of Virtual Machine Cloud Management from the Azure supports deploying and managing VMs on your Azure Stack Edge device from Azure Portal. + For more information, refer to: https://docs.microsoft.com/en-us/azure/databox-online/azure-stack-edge-gpu-virtual-machine-overview + By using this feature, you agree to the preview legal terms. See the https://azure.microsoft.com/en-us/support/legal/preview-supplemental-terms/ for additional details. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleTypes + :ivar system_data: Role configured on ASE resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar local_management_status: Local Edge Management Status. Known values are: "Enabled" and + "Disabled". + :vartype local_management_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleStatus + :ivar edge_profile: Edge Profile of the resource. + :vartype edge_profile: ~azure.mgmt.databoxedge.v2021_02_01.models.EdgeProfile + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "local_management_status": {"readonly": True}, + "edge_profile": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "local_management_status": {"key": "properties.localManagementStatus", "type": "str"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, + } + + def __init__(self, *, role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs): + """ + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "CloudEdgeManagement" + self.local_management_status = None + self.edge_profile = None + self.role_status = role_status + + +class CloudErrorBody(_serialization.Model): + """An error response from the service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.databoxedge.v2021_02_01.models.CloudErrorBody] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.databoxedge.v2021_02_01.models.CloudErrorBody] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.details = details + + +class CniConfig(_serialization.Model): + """Cni configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: Cni type. + :vartype type: str + :ivar version: Cni version. + :vartype version: str + :ivar pod_subnet: Pod Subnet. + :vartype pod_subnet: str + :ivar service_subnet: Service subnet. + :vartype service_subnet: str + """ + + _validation = { + "type": {"readonly": True}, + "version": {"readonly": True}, + "pod_subnet": {"readonly": True}, + "service_subnet": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "pod_subnet": {"key": "podSubnet", "type": "str"}, + "service_subnet": {"key": "serviceSubnet", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None + self.version = None + self.pod_subnet = None + self.service_subnet = None + + +class ComputeResource(_serialization.Model): + """Compute infrastructure Resource. + + All required parameters must be populated in order to send to Azure. + + :ivar processor_count: Processor count. Required. + :vartype processor_count: int + :ivar memory_in_gb: Memory in GB. Required. + :vartype memory_in_gb: int + """ + + _validation = { + "processor_count": {"required": True}, + "memory_in_gb": {"required": True}, + } + + _attribute_map = { + "processor_count": {"key": "processorCount", "type": "int"}, + "memory_in_gb": {"key": "memoryInGB", "type": "int"}, + } + + def __init__(self, *, processor_count: int, memory_in_gb: int, **kwargs): + """ + :keyword processor_count: Processor count. Required. + :paramtype processor_count: int + :keyword memory_in_gb: Memory in GB. Required. + :paramtype memory_in_gb: int + """ + super().__init__(**kwargs) + self.processor_count = processor_count + self.memory_in_gb = memory_in_gb + + +class ContactDetails(_serialization.Model): + """Contains all the contact details of the customer. + + All required parameters must be populated in order to send to Azure. + + :ivar contact_person: The contact person name. Required. + :vartype contact_person: str + :ivar company_name: The name of the company. Required. + :vartype company_name: str + :ivar phone: The phone number. Required. + :vartype phone: str + :ivar email_list: The email list. Required. + :vartype email_list: list[str] + """ + + _validation = { + "contact_person": {"required": True}, + "company_name": {"required": True}, + "phone": {"required": True}, + "email_list": {"required": True}, + } + + _attribute_map = { + "contact_person": {"key": "contactPerson", "type": "str"}, + "company_name": {"key": "companyName", "type": "str"}, + "phone": {"key": "phone", "type": "str"}, + "email_list": {"key": "emailList", "type": "[str]"}, + } + + def __init__(self, *, contact_person: str, company_name: str, phone: str, email_list: List[str], **kwargs): + """ + :keyword contact_person: The contact person name. Required. + :paramtype contact_person: str + :keyword company_name: The name of the company. Required. + :paramtype company_name: str + :keyword phone: The phone number. Required. + :paramtype phone: str + :keyword email_list: The email list. Required. + :paramtype email_list: list[str] + """ + super().__init__(**kwargs) + self.contact_person = contact_person + self.company_name = company_name + self.phone = phone + self.email_list = email_list + + +class Container(ARMBaseModel): + """Represents a container on the Data Box Edge/Gateway device. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: Container in DataBoxEdge Resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar container_status: Current status of the container. Known values are: "OK", "Offline", + "Unknown", "Updating", and "NeedsAttention". + :vartype container_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ContainerStatus + :ivar data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :vartype data_format: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.AzureContainerDataFormat + :ivar refresh_details: Details of the refresh job on this container. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2021_02_01.models.RefreshDetails + :ivar created_date_time: The UTC time when container got created. + :vartype created_date_time: ~datetime.datetime + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "container_status": {"readonly": True}, + "data_format": {"required": True}, + "refresh_details": {"readonly": True}, + "created_date_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "container_status": {"key": "properties.containerStatus", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, + } + + def __init__(self, *, data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs): + """ + :keyword data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) + self.system_data = None + self.container_status = None + self.data_format = data_format + self.refresh_details = None + self.created_date_time = None + + +class ContainerList(_serialization.Model): + """Collection of all the containers on the Data Box Edge/Gateway device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of containers. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Container] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Container]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class DataBoxEdgeDevice(ARMBaseModel): # pylint: disable=too-many-instance-attributes + """The Data Box Edge/Gateway device. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :vartype location: str + :ivar tags: The list of tags that describe the device. These tags can be used to view and group + this device (across resource groups). + :vartype tags: dict[str, str] + :ivar sku: The SKU type. + :vartype sku: ~azure.mgmt.databoxedge.v2021_02_01.models.Sku + :ivar etag: The etag for the devices. + :vartype etag: str + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2021_02_01.models.ResourceIdentity + :ivar kind: The kind of the device. Known values are: "AzureDataBoxGateway", "AzureStackEdge", + "AzureStackHub", and "AzureModularDataCentre". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceKind + :ivar system_data: DataBoxEdge Resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar system_data_properties_system_data: DataBoxEdge Device Properties. + :vartype system_data_properties_system_data: + ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known values + are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :vartype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceStatus + :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. + :vartype serial_number: str + :ivar description: The Description of the Data Box Edge/Gateway device. + :vartype description: str + :ivar model_description: The description of the Data Box Edge/Gateway device model. + :vartype model_description: str + :ivar device_type: The type of the Data Box Edge/Gateway device. "DataBoxEdgeDevice" + :vartype device_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DeviceType + :ivar friendly_name: The Data Box Edge/Gateway device name. + :vartype friendly_name: str + :ivar culture: The Data Box Edge/Gateway device culture. + :vartype culture: str + :ivar device_model: The Data Box Edge/Gateway device model. + :vartype device_model: str + :ivar device_software_version: The Data Box Edge/Gateway device software version. + :vartype device_software_version: str + :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. + :vartype device_local_capacity: int + :ivar time_zone: The Data Box Edge/Gateway device timezone. + :vartype time_zone: str + :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). + :vartype device_hcs_version: str + :ivar configured_role_types: Type of compute roles configured. + :vartype configured_role_types: list[str or + ~azure.mgmt.databoxedge.v2021_02_01.models.RoleTypes] + :ivar node_count: The number of nodes in the cluster. + :vartype node_count: int + :ivar resource_move_details: The details of the move operation on this resource. + :vartype resource_move_details: ~azure.mgmt.databoxedge.v2021_02_01.models.ResourceMoveDetails + :ivar edge_profile: The details of Edge Profile for this resource. + :vartype edge_profile: ~azure.mgmt.databoxedge.v2021_02_01.models.EdgeProfile + :ivar data_residency: The details of data-residency related properties for this resource. + :vartype data_residency: ~azure.mgmt.databoxedge.v2021_02_01.models.DataResidency + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "system_data_properties_system_data": {"readonly": True}, + "serial_number": {"readonly": True}, + "description": {"readonly": True}, + "model_description": {"readonly": True}, + "device_type": {"readonly": True}, + "friendly_name": {"readonly": True}, + "culture": {"readonly": True}, + "device_model": {"readonly": True}, + "device_software_version": {"readonly": True}, + "device_local_capacity": {"readonly": True}, + "time_zone": {"readonly": True}, + "device_hcs_version": {"readonly": True}, + "configured_role_types": {"readonly": True}, + "node_count": {"readonly": True}, + "resource_move_details": {"readonly": True}, + "edge_profile": {"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}"}, + "sku": {"key": "sku", "type": "Sku"}, + "etag": {"key": "etag", "type": "str"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "system_data_properties_system_data": {"key": "properties.systemData", "type": "SystemData"}, + "data_box_edge_device_status": {"key": "properties.dataBoxEdgeDeviceStatus", "type": "str"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "model_description": {"key": "properties.modelDescription", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "culture": {"key": "properties.culture", "type": "str"}, + "device_model": {"key": "properties.deviceModel", "type": "str"}, + "device_software_version": {"key": "properties.deviceSoftwareVersion", "type": "str"}, + "device_local_capacity": {"key": "properties.deviceLocalCapacity", "type": "int"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "device_hcs_version": {"key": "properties.deviceHcsVersion", "type": "str"}, + "configured_role_types": {"key": "properties.configuredRoleTypes", "type": "[str]"}, + "node_count": {"key": "properties.nodeCount", "type": "int"}, + "resource_move_details": {"key": "properties.resourceMoveDetails", "type": "ResourceMoveDetails"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + "data_residency": {"key": "properties.dataResidency", "type": "DataResidency"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.Sku"] = None, + etag: Optional[str] = None, + identity: Optional["_models.ResourceIdentity"] = None, + kind: Optional[Union[str, "_models.DataBoxEdgeDeviceKind"]] = None, + data_box_edge_device_status: Optional[Union[str, "_models.DataBoxEdgeDeviceStatus"]] = None, + data_residency: Optional["_models.DataResidency"] = None, + **kwargs + ): + """ + :keyword location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :paramtype location: str + :keyword tags: The list of tags that describe the device. These tags can be used to view and + group this device (across resource groups). + :paramtype tags: dict[str, str] + :keyword sku: The SKU type. + :paramtype sku: ~azure.mgmt.databoxedge.v2021_02_01.models.Sku + :keyword etag: The etag for the devices. + :paramtype etag: str + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2021_02_01.models.ResourceIdentity + :keyword kind: The kind of the device. Known values are: "AzureDataBoxGateway", + "AzureStackEdge", "AzureStackHub", and "AzureModularDataCentre". + :paramtype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceKind + :keyword data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known + values are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :paramtype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceStatus + :keyword data_residency: The details of data-residency related properties for this resource. + :paramtype data_residency: ~azure.mgmt.databoxedge.v2021_02_01.models.DataResidency + """ + super().__init__(**kwargs) + self.location = location + self.tags = tags + self.sku = sku + self.etag = etag + self.identity = identity + self.kind = kind + self.system_data = None + self.system_data_properties_system_data = None + self.data_box_edge_device_status = data_box_edge_device_status + self.serial_number = None + self.description = None + self.model_description = None + self.device_type = None + self.friendly_name = None + self.culture = None + self.device_model = None + self.device_software_version = None + self.device_local_capacity = None + self.time_zone = None + self.device_hcs_version = None + self.configured_role_types = None + self.node_count = None + self.resource_move_details = None + self.edge_profile = None + self.data_residency = data_residency + + +class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): # pylint: disable=too-many-instance-attributes + """The extended Info of the Data Box Edge/Gateway device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar encryption_key_thumbprint: The digital signature of encrypted certificate. + :vartype encryption_key_thumbprint: str + :ivar encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :vartype encryption_key: str + :ivar resource_key: The Resource ID of the Resource. + :vartype resource_key: str + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + Vault. + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + Key Vault. + :vartype channel_integrity_key_version: str + :ivar key_vault_sync_status: Key vault sync status. Known values are: "KeyVaultSynced", + "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", "KeyVaultSyncing", and + "KeyVaultNotSynced". + :vartype key_vault_sync_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.KeyVaultSyncStatus + :ivar device_secrets: Device secrets, will be returned only with ODataFilter + $expand=deviceSecrets. + :vartype device_secrets: dict[str, ~azure.mgmt.databoxedge.v2021_02_01.models.Secret] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_key": {"readonly": True}, + "device_secrets": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encryption_key_thumbprint": {"key": "properties.encryptionKeyThumbprint", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "str"}, + "resource_key": {"key": "properties.resourceKey", "type": "str"}, + "client_secret_store_id": {"key": "properties.clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "properties.clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "properties.channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "properties.channelIntegrityKeyVersion", "type": "str"}, + "key_vault_sync_status": {"key": "properties.keyVaultSyncStatus", "type": "str"}, + "device_secrets": {"key": "properties.deviceSecrets", "type": "{Secret}"}, + } + + def __init__( + self, + *, + encryption_key_thumbprint: Optional[str] = None, + encryption_key: Optional[str] = None, + client_secret_store_id: Optional[str] = None, + client_secret_store_url: Optional[str] = None, + channel_integrity_key_name: Optional[str] = None, + channel_integrity_key_version: Optional[str] = None, + key_vault_sync_status: Optional[Union[str, "_models.KeyVaultSyncStatus"]] = None, + **kwargs + ): + """ + :keyword encryption_key_thumbprint: The digital signature of encrypted certificate. + :paramtype encryption_key_thumbprint: str + :keyword encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :paramtype encryption_key: str + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + :keyword key_vault_sync_status: Key vault sync status. Known values are: "KeyVaultSynced", + "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", "KeyVaultSyncing", and + "KeyVaultNotSynced". + :paramtype key_vault_sync_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.KeyVaultSyncStatus + """ + super().__init__(**kwargs) + self.encryption_key_thumbprint = encryption_key_thumbprint + self.encryption_key = encryption_key + self.resource_key = None + self.client_secret_store_id = client_secret_store_id + self.client_secret_store_url = client_secret_store_url + self.channel_integrity_key_name = channel_integrity_key_name + self.channel_integrity_key_version = channel_integrity_key_version + self.key_vault_sync_status = key_vault_sync_status + self.device_secrets = None + + +class DataBoxEdgeDeviceExtendedInfoPatch(_serialization.Model): + """The Data Box Edge/Gateway device extended info patch. + + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key + Vault. + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + Key Vault. + :vartype channel_integrity_key_version: str + :ivar sync_status: For changing or to initiate the resync to key-vault set the status to + KeyVaultSyncPending, rest of the status will not be applicable. Known values are: + "KeyVaultSynced", "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", + "KeyVaultSyncing", and "KeyVaultNotSynced". + :vartype sync_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.KeyVaultSyncStatus + """ + + _attribute_map = { + "client_secret_store_id": {"key": "clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "channelIntegrityKeyVersion", "type": "str"}, + "sync_status": {"key": "syncStatus", "type": "str"}, + } + + def __init__( + self, + *, + client_secret_store_id: Optional[str] = None, + client_secret_store_url: Optional[str] = None, + channel_integrity_key_name: Optional[str] = None, + channel_integrity_key_version: Optional[str] = None, + sync_status: Optional[Union[str, "_models.KeyVaultSyncStatus"]] = None, + **kwargs + ): + """ + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name for Channel Integrity Key stored in the Client + Key Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + :keyword sync_status: For changing or to initiate the resync to key-vault set the status to + KeyVaultSyncPending, rest of the status will not be applicable. Known values are: + "KeyVaultSynced", "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", + "KeyVaultSyncing", and "KeyVaultNotSynced". + :paramtype sync_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.KeyVaultSyncStatus + """ + super().__init__(**kwargs) + self.client_secret_store_id = client_secret_store_id + self.client_secret_store_url = client_secret_store_url + self.channel_integrity_key_name = channel_integrity_key_name + self.channel_integrity_key_version = channel_integrity_key_version + self.sync_status = sync_status + + +class DataBoxEdgeDeviceList(_serialization.Model): + """The collection of Data Box Edge/Gateway devices. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of Data Box Edge/Gateway devices. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[DataBoxEdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class DataBoxEdgeDevicePatch(_serialization.Model): + """The Data Box Edge/Gateway device patch. + + :ivar tags: The tags attached to the Data Box Edge/Gateway resource. + :vartype tags: dict[str, str] + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2021_02_01.models.ResourceIdentity + :ivar edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :vartype edge_profile: ~azure.mgmt.databoxedge.v2021_02_01.models.EdgeProfilePatch + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfilePatch"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.ResourceIdentity"] = None, + edge_profile: Optional["_models.EdgeProfilePatch"] = None, + **kwargs + ): + """ + :keyword tags: The tags attached to the Data Box Edge/Gateway resource. + :paramtype tags: dict[str, str] + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2021_02_01.models.ResourceIdentity + :keyword edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :paramtype edge_profile: ~azure.mgmt.databoxedge.v2021_02_01.models.EdgeProfilePatch + """ + super().__init__(**kwargs) + self.tags = tags + self.identity = identity + self.edge_profile = edge_profile + + +class DataBoxEdgeMoveRequest(_serialization.Model): + """Resource Move details. + + All required parameters must be populated in order to send to Azure. + + :ivar target_resource_group: Target resource group ARMId. Required. + :vartype target_resource_group: str + :ivar resources: List of resources to be moved. Required. + :vartype resources: list[str] + """ + + _validation = { + "target_resource_group": {"required": True}, + "resources": {"required": True}, + } + + _attribute_map = { + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, + "resources": {"key": "resources", "type": "[str]"}, + } + + def __init__(self, *, target_resource_group: str, resources: List[str], **kwargs): + """ + :keyword target_resource_group: Target resource group ARMId. Required. + :paramtype target_resource_group: str + :keyword resources: List of resources to be moved. Required. + :paramtype resources: list[str] + """ + super().__init__(**kwargs) + self.target_resource_group = target_resource_group + self.resources = resources + + +class DataBoxEdgeSku(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The Sku information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_type: The type of the resource. + :vartype resource_type: str + :ivar name: The Sku name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", "EP2_256_2T4_W", "EdgeMR_Mini", + "RCA_Small", "RCA_Large", "RDC", and "Management". + :vartype name: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SkuName + :ivar kind: The Sku kind. + :vartype kind: str + :ivar tier: The Sku tier. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SkuTier + :ivar size: The Sku kind. + :vartype size: str + :ivar family: The Sku family. + :vartype family: str + :ivar locations: Availability of the Sku for the region. + :vartype locations: list[str] + :ivar api_versions: The API versions in which Sku is available. + :vartype api_versions: list[str] + :ivar location_info: Availability of the Sku for the location/zone/site. + :vartype location_info: list[~azure.mgmt.databoxedge.v2021_02_01.models.SkuLocationInfo] + :ivar costs: The pricing info of the Sku. + :vartype costs: list[~azure.mgmt.databoxedge.v2021_02_01.models.SkuCost] + :ivar signup_option: Sku can be signed up by customer or not. Known values are: "None" and + "Available". + :vartype signup_option: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SkuSignupOption + :ivar version: Availability of the Sku as preview/stable. Known values are: "Stable" and + "Preview". + :vartype version: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SkuVersion + :ivar availability: Links to the next set of results. Known values are: "Available" and + "Unavailable". + :vartype availability: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SkuAvailability + :ivar shipment_types: List of Shipment Types supported by this SKU. + :vartype shipment_types: list[str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShipmentType] + :ivar capabilities: The capability info of the SKU. + :vartype capabilities: list[~azure.mgmt.databoxedge.v2021_02_01.models.SkuCapability] + """ + + _validation = { + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "kind": {"readonly": True}, + "tier": {"readonly": True}, + "size": {"readonly": True}, + "family": {"readonly": True}, + "locations": {"readonly": True}, + "api_versions": {"readonly": True}, + "location_info": {"readonly": True}, + "costs": {"readonly": True}, + "signup_option": {"readonly": True}, + "version": {"readonly": True}, + "availability": {"readonly": True}, + "shipment_types": {"readonly": True}, + "capabilities": {"readonly": True}, + } + + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "signup_option": {"key": "signupOption", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "availability": {"key": "availability", "type": "str"}, + "shipment_types": {"key": "shipmentTypes", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SkuCapability]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.resource_type = None + self.name = None + self.kind = None + self.tier = None + self.size = None + self.family = None + self.locations = None + self.api_versions = None + self.location_info = None + self.costs = None + self.signup_option = None + self.version = None + self.availability = None + self.shipment_types = None + self.capabilities = None + + +class DataBoxEdgeSkuList(_serialization.Model): + """List of SKU Information objects. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of ResourceType Sku. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeSku] + :ivar next_link: Links to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[DataBoxEdgeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class DataResidency(_serialization.Model): + """Wraps data-residency related information for edge-resource and this should be used with ARM layer. + + :ivar type: DataResidencyType enum. Known values are: "GeoZoneReplication" and + "ZoneReplication". + :vartype type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DataResidencyType + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.DataResidencyType"]] = None, **kwargs): + """ + :keyword type: DataResidencyType enum. Known values are: "GeoZoneReplication" and + "ZoneReplication". + :paramtype type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DataResidencyType + """ + super().__init__(**kwargs) + self.type = type + + +class DCAccessCode(_serialization.Model): + """DC Access code in the case of Self Managed Shipping. + + :ivar auth_code: DCAccess Code for the Self Managed shipment. + :vartype auth_code: str + """ + + _attribute_map = { + "auth_code": {"key": "properties.authCode", "type": "str"}, + } + + def __init__(self, *, auth_code: Optional[str] = None, **kwargs): + """ + :keyword auth_code: DCAccess Code for the Self Managed shipment. + :paramtype auth_code: str + """ + super().__init__(**kwargs) + self.auth_code = auth_code + + +class DiagnosticProactiveLogCollectionSettings(ARMBaseModel): + """The diagnostic proactive log collection settings of a device. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: DiagnosticProactiveLogCollectionSettings. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar user_consent: Proactive diagnostic collection consent flag. Required. Known values are: + "Enabled" and "Disabled". + :vartype user_consent: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.ProactiveDiagnosticsConsent + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "user_consent": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "user_consent": {"key": "properties.userConsent", "type": "str"}, + } + + def __init__(self, *, user_consent: Union[str, "_models.ProactiveDiagnosticsConsent"], **kwargs): + """ + :keyword user_consent: Proactive diagnostic collection consent flag. Required. Known values + are: "Enabled" and "Disabled". + :paramtype user_consent: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.ProactiveDiagnosticsConsent + """ + super().__init__(**kwargs) + self.system_data = None + self.user_consent = user_consent + + +class DiagnosticRemoteSupportSettings(ARMBaseModel): + """The remote support settings of a device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: DiagnosticRemoteSupportSettings. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar remote_support_settings_list: Remote support settings list according to the + RemoteApplicationType. + :vartype remote_support_settings_list: + list[~azure.mgmt.databoxedge.v2021_02_01.models.RemoteSupportSettings] + """ + + _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"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "remote_support_settings_list": { + "key": "properties.remoteSupportSettingsList", + "type": "[RemoteSupportSettings]", + }, + } + + def __init__( + self, *, remote_support_settings_list: Optional[List["_models.RemoteSupportSettings"]] = None, **kwargs + ): + """ + :keyword remote_support_settings_list: Remote support settings list according to the + RemoteApplicationType. + :paramtype remote_support_settings_list: + list[~azure.mgmt.databoxedge.v2021_02_01.models.RemoteSupportSettings] + """ + super().__init__(**kwargs) + self.system_data = None + self.remote_support_settings_list = remote_support_settings_list + + +class EdgeProfile(_serialization.Model): + """Details about Edge Profile for the resource. + + :ivar subscription: Edge Profile Subscription. + :vartype subscription: ~azure.mgmt.databoxedge.v2021_02_01.models.EdgeProfileSubscription + """ + + _attribute_map = { + "subscription": {"key": "subscription", "type": "EdgeProfileSubscription"}, + } + + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscription"] = None, **kwargs): + """ + :keyword subscription: Edge Profile Subscription. + :paramtype subscription: ~azure.mgmt.databoxedge.v2021_02_01.models.EdgeProfileSubscription + """ + super().__init__(**kwargs) + self.subscription = subscription + + +class EdgeProfilePatch(_serialization.Model): + """The Data Box Edge/Gateway Edge Profile patch. + + :ivar subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :vartype subscription: ~azure.mgmt.databoxedge.v2021_02_01.models.EdgeProfileSubscriptionPatch + """ + + _attribute_map = { + "subscription": {"key": "subscription", "type": "EdgeProfileSubscriptionPatch"}, + } + + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscriptionPatch"] = None, **kwargs): + """ + :keyword subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :paramtype subscription: + ~azure.mgmt.databoxedge.v2021_02_01.models.EdgeProfileSubscriptionPatch + """ + super().__init__(**kwargs) + self.subscription = subscription + + +class EdgeProfileSubscription(_serialization.Model): + """Subscription details for the Edge Profile. + + :ivar registration_id: Edge Subscription Registration ID. + :vartype registration_id: str + :ivar id: ARM ID of the subscription. + :vartype id: str + :ivar state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and + "Unregistered". + :vartype state: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SubscriptionState + :ivar registration_date: + :vartype registration_date: str + :ivar subscription_id: + :vartype subscription_id: str + :ivar tenant_id: + :vartype tenant_id: str + :ivar location_placement_id: + :vartype location_placement_id: str + :ivar quota_id: + :vartype quota_id: str + :ivar serialized_details: + :vartype serialized_details: str + :ivar registered_features: + :vartype registered_features: + list[~azure.mgmt.databoxedge.v2021_02_01.models.SubscriptionRegisteredFeatures] + """ + + _attribute_map = { + "registration_id": {"key": "registrationId", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "registration_date": {"key": "registrationDate", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "location_placement_id": {"key": "properties.locationPlacementId", "type": "str"}, + "quota_id": {"key": "properties.quotaId", "type": "str"}, + "serialized_details": {"key": "properties.serializedDetails", "type": "str"}, + "registered_features": {"key": "properties.registeredFeatures", "type": "[SubscriptionRegisteredFeatures]"}, + } + + def __init__( + self, + *, + registration_id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + state: Optional[Union[str, "_models.SubscriptionState"]] = None, + registration_date: Optional[str] = None, + subscription_id: Optional[str] = None, + tenant_id: Optional[str] = None, + location_placement_id: Optional[str] = None, + quota_id: Optional[str] = None, + serialized_details: Optional[str] = None, + registered_features: Optional[List["_models.SubscriptionRegisteredFeatures"]] = None, + **kwargs + ): + """ + :keyword registration_id: Edge Subscription Registration ID. + :paramtype registration_id: str + :keyword id: ARM ID of the subscription. + :paramtype id: str + :keyword state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and + "Unregistered". + :paramtype state: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SubscriptionState + :keyword registration_date: + :paramtype registration_date: str + :keyword subscription_id: + :paramtype subscription_id: str + :keyword tenant_id: + :paramtype tenant_id: str + :keyword location_placement_id: + :paramtype location_placement_id: str + :keyword quota_id: + :paramtype quota_id: str + :keyword serialized_details: + :paramtype serialized_details: str + :keyword registered_features: + :paramtype registered_features: + list[~azure.mgmt.databoxedge.v2021_02_01.models.SubscriptionRegisteredFeatures] + """ + super().__init__(**kwargs) + self.registration_id = registration_id + self.id = id + self.state = state + self.registration_date = registration_date + self.subscription_id = subscription_id + self.tenant_id = tenant_id + self.location_placement_id = location_placement_id + self.quota_id = quota_id + self.serialized_details = serialized_details + self.registered_features = registered_features + + +class EdgeProfileSubscriptionPatch(_serialization.Model): + """The Data Box Edge/Gateway Edge Profile Subscription patch. + + :ivar id: The path ID that uniquely identifies the subscription of the edge profile. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The path ID that uniquely identifies the subscription of the edge profile. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class EtcdInfo(_serialization.Model): + """Etcd configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: Etcd type. + :vartype type: str + :ivar version: Etcd version. + :vartype version: str + """ + + _validation = { + "type": {"readonly": True}, + "version": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None + self.version = None + + +class Trigger(ARMBaseModel): + """Trigger details. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FileEventTrigger, PeriodicTimerEventTrigger + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: Trigger in DataBoxEdge Resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.TriggerEventType + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + } + + _subtype_map = {"kind": {"FileEvent": "FileEventTrigger", "PeriodicTimerEvent": "PeriodicTimerEventTrigger"}} + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.system_data = None + self.kind: Optional[str] = None + + +class FileEventTrigger(Trigger): + """Trigger details. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: Trigger in DataBoxEdge Resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.TriggerEventType + :ivar source_info: File event source details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2021_02_01.models.FileSourceInfo + :ivar sink_info: Role sink info. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2021_02_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against + its usage. For example, if a periodic timer trigger is intended for certain specific IoT + modules in the device, the tag can be the name or the image URL of the module. + :vartype custom_context_tag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "FileSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, + } + + def __init__( + self, + *, + source_info: "_models.FileSourceInfo", + sink_info: "_models.RoleSinkInfo", + custom_context_tag: Optional[str] = None, + **kwargs + ): + """ + :keyword source_info: File event source details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2021_02_01.models.FileSourceInfo + :keyword sink_info: Role sink info. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2021_02_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "FileEvent" + self.source_info = source_info + self.sink_info = sink_info + self.custom_context_tag = custom_context_tag + + +class FileSourceInfo(_serialization.Model): + """File source details. + + All required parameters must be populated in order to send to Azure. + + :ivar share_id: File share ID. Required. + :vartype share_id: str + """ + + _validation = { + "share_id": {"required": True}, + } + + _attribute_map = { + "share_id": {"key": "shareId", "type": "str"}, + } + + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: File share ID. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) + self.share_id = share_id + + +class GenerateCertResponse(_serialization.Model): + """Used in activation key generation flow. + + :ivar public_key: Gets or sets base64 encoded certificate raw data, + this is the public part needed to be uploaded to cert vault. + :vartype public_key: str + :ivar private_key: Gets or sets base64 encoded private part of the certificate, + needed to form the activation key. + :vartype private_key: str + :ivar expiry_time_in_utc: Gets or sets expiry time in UTC. + :vartype expiry_time_in_utc: str + """ + + _attribute_map = { + "public_key": {"key": "publicKey", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "expiry_time_in_utc": {"key": "expiryTimeInUTC", "type": "str"}, + } + + def __init__( + self, + *, + public_key: Optional[str] = None, + private_key: Optional[str] = None, + expiry_time_in_utc: Optional[str] = None, + **kwargs + ): + """ + :keyword public_key: Gets or sets base64 encoded certificate raw data, + this is the public part needed to be uploaded to cert vault. + :paramtype public_key: str + :keyword private_key: Gets or sets base64 encoded private part of the certificate, + needed to form the activation key. + :paramtype private_key: str + :keyword expiry_time_in_utc: Gets or sets expiry time in UTC. + :paramtype expiry_time_in_utc: str + """ + super().__init__(**kwargs) + self.public_key = public_key + self.private_key = private_key + self.expiry_time_in_utc = expiry_time_in_utc + + +class ImageRepositoryCredential(_serialization.Model): + """Image repository credential. + + All required parameters must be populated in order to send to Azure. + + :ivar image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :vartype image_repository_url: str + :ivar user_name: Repository user name. Required. + :vartype user_name: str + :ivar password: Repository user password. + :vartype password: ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + """ + + _validation = { + "image_repository_url": {"required": True}, + "user_name": {"required": True}, + } + + _attribute_map = { + "image_repository_url": {"key": "imageRepositoryUrl", "type": "str"}, + "user_name": {"key": "userName", "type": "str"}, + "password": {"key": "password", "type": "AsymmetricEncryptedSecret"}, + } + + def __init__( + self, + *, + image_repository_url: str, + user_name: str, + password: Optional["_models.AsymmetricEncryptedSecret"] = None, + **kwargs + ): + """ + :keyword image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :paramtype image_repository_url: str + :keyword user_name: Repository user name. Required. + :paramtype user_name: str + :keyword password: Repository user password. + :paramtype password: ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) + self.image_repository_url = image_repository_url + self.user_name = user_name + self.password = password + + +class IoTAddon(Addon): # pylint: disable=too-many-instance-attributes + """IoT Addon. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AddonType + :ivar system_data: Addon type. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be configured. + Required. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTDeviceInfo + :ivar version: Version of IoT running on the appliance. + :vartype version: str + :ivar host_platform: Host OS supported by the IoT addon. Known values are: "Windows" and + "Linux". + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01.models.PlatformType + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". + :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.HostPlatformType + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AddonState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "io_t_device_details": {"required": True}, + "io_t_edge_device_details": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + io_t_device_details: "_models.IoTDeviceInfo", + io_t_edge_device_details: "_models.IoTDeviceInfo", + **kwargs + ): + """ + :keyword io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :paramtype io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be + configured. Required. + :paramtype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTDeviceInfo + """ + super().__init__(**kwargs) + self.kind: str = "IotEdge" + self.io_t_device_details = io_t_device_details + self.io_t_edge_device_details = io_t_edge_device_details + self.version = None + self.host_platform = None + self.host_platform_type = None + self.provisioning_state = None + + +class IoTDeviceInfo(_serialization.Model): + """Metadata of IoT device/IoT Edge device to be configured. + + All required parameters must be populated in order to send to Azure. + + :ivar device_id: ID of the IoT device/edge device. Required. + :vartype device_id: str + :ivar io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :vartype io_t_host_hub: str + :ivar io_t_host_hub_id: Id for the IoT hub associated to the device. + :vartype io_t_host_hub_id: str + :ivar authentication: Encrypted IoT device/IoT edge device connection string. + :vartype authentication: ~azure.mgmt.databoxedge.v2021_02_01.models.Authentication + """ + + _validation = { + "device_id": {"required": True}, + "io_t_host_hub": {"required": True}, + } + + _attribute_map = { + "device_id": {"key": "deviceId", "type": "str"}, + "io_t_host_hub": {"key": "ioTHostHub", "type": "str"}, + "io_t_host_hub_id": {"key": "ioTHostHubId", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, + } + + def __init__( + self, + *, + device_id: str, + io_t_host_hub: str, + io_t_host_hub_id: Optional[str] = None, + authentication: Optional["_models.Authentication"] = None, + **kwargs + ): + """ + :keyword device_id: ID of the IoT device/edge device. Required. + :paramtype device_id: str + :keyword io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :paramtype io_t_host_hub: str + :keyword io_t_host_hub_id: Id for the IoT hub associated to the device. + :paramtype io_t_host_hub_id: str + :keyword authentication: Encrypted IoT device/IoT edge device connection string. + :paramtype authentication: ~azure.mgmt.databoxedge.v2021_02_01.models.Authentication + """ + super().__init__(**kwargs) + self.device_id = device_id + self.io_t_host_hub = io_t_host_hub + self.io_t_host_hub_id = io_t_host_hub_id + self.authentication = authentication + + +class IoTEdgeAgentInfo(_serialization.Model): + """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. + + All required parameters must be populated in order to send to Azure. + + :ivar image_name: Name of the IoT edge agent image. Required. + :vartype image_name: str + :ivar tag: Image Tag. Required. + :vartype tag: str + :ivar image_repository: Image repository details. + :vartype image_repository: ~azure.mgmt.databoxedge.v2021_02_01.models.ImageRepositoryCredential + """ + + _validation = { + "image_name": {"required": True}, + "tag": {"required": True}, + } + + _attribute_map = { + "image_name": {"key": "imageName", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "image_repository": {"key": "imageRepository", "type": "ImageRepositoryCredential"}, + } + + def __init__( + self, + *, + image_name: str, + tag: str, + image_repository: Optional["_models.ImageRepositoryCredential"] = None, + **kwargs + ): + """ + :keyword image_name: Name of the IoT edge agent image. Required. + :paramtype image_name: str + :keyword tag: Image Tag. Required. + :paramtype tag: str + :keyword image_repository: Image repository details. + :paramtype image_repository: + ~azure.mgmt.databoxedge.v2021_02_01.models.ImageRepositoryCredential + """ + super().__init__(**kwargs) + self.image_name = image_name + self.tag = tag + self.image_repository = image_repository + + +class IoTRole(Role): # pylint: disable=too-many-instance-attributes + """Compute role. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleTypes + :ivar system_data: Role configured on ASE resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01.models.PlatformType + :ivar io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTDeviceInfo + :ivar share_mappings: Mount points of shares in role(s). + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2021_02_01.models.MountPointMap] + :ivar io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + runtime. + :vartype io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTEdgeAgentInfo + :ivar host_platform_type: Platform where the Iot runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". + :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.HostPlatformType + :ivar compute_resource: Resource allocation. + :vartype compute_resource: ~azure.mgmt.databoxedge.v2021_02_01.models.ComputeResource + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "host_platform_type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "io_t_edge_agent_info": {"key": "properties.ioTEdgeAgentInfo", "type": "IoTEdgeAgentInfo"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "compute_resource": {"key": "properties.computeResource", "type": "ComputeResource"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, + } + + def __init__( + self, + *, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + io_t_device_details: Optional["_models.IoTDeviceInfo"] = None, + io_t_edge_device_details: Optional["_models.IoTDeviceInfo"] = None, + share_mappings: Optional[List["_models.MountPointMap"]] = None, + io_t_edge_agent_info: Optional["_models.IoTEdgeAgentInfo"] = None, + compute_resource: Optional["_models.ComputeResource"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, + **kwargs + ): + """ + :keyword host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :paramtype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01.models.PlatformType + :keyword io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :paramtype io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT role needs to be + configured. + :paramtype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTDeviceInfo + :keyword share_mappings: Mount points of shares in role(s). + :paramtype share_mappings: list[~azure.mgmt.databoxedge.v2021_02_01.models.MountPointMap] + :keyword io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + runtime. + :paramtype io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2021_02_01.models.IoTEdgeAgentInfo + :keyword compute_resource: Resource allocation. + :paramtype compute_resource: ~azure.mgmt.databoxedge.v2021_02_01.models.ComputeResource + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "IOT" + self.host_platform = host_platform + self.io_t_device_details = io_t_device_details + self.io_t_edge_device_details = io_t_edge_device_details + self.share_mappings = share_mappings + self.io_t_edge_agent_info = io_t_edge_agent_info + self.host_platform_type = None + self.compute_resource = compute_resource + self.role_status = role_status + + +class Ipv4Config(_serialization.Model): + """Details related to the IPv4 address configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ip_address: The IPv4 address of the network adapter. + :vartype ip_address: str + :ivar subnet: The IPv4 subnet of the network adapter. + :vartype subnet: str + :ivar gateway: The IPv4 gateway of the network adapter. + :vartype gateway: str + """ + + _validation = { + "ip_address": {"readonly": True}, + "subnet": {"readonly": True}, + "gateway": {"readonly": True}, + } + + _attribute_map = { + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.ip_address = None + self.subnet = None + self.gateway = None + + +class Ipv6Config(_serialization.Model): + """Details related to the IPv6 address configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ip_address: The IPv6 address of the network adapter. + :vartype ip_address: str + :ivar prefix_length: The IPv6 prefix of the network adapter. + :vartype prefix_length: int + :ivar gateway: The IPv6 gateway of the network adapter. + :vartype gateway: str + """ + + _validation = { + "ip_address": {"readonly": True}, + "prefix_length": {"readonly": True}, + "gateway": {"readonly": True}, + } + + _attribute_map = { + "ip_address": {"key": "ipAddress", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "int"}, + "gateway": {"key": "gateway", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.ip_address = None + self.prefix_length = None + self.gateway = None + + +class Job(_serialization.Model): # pylint: disable=too-many-instance-attributes + """A device job. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The name of the object. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar status: The current status of the job. Known values are: "Invalid", "Running", + "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". + :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.JobStatus + :ivar start_time: The UTC date and time at which the job started. + :vartype start_time: ~datetime.datetime + :ivar end_time: The UTC date and time at which the job completed. + :vartype end_time: ~datetime.datetime + :ivar percent_complete: The percentage of the job that is complete. + :vartype percent_complete: int + :ivar error: The error details. + :vartype error: ~azure.mgmt.databoxedge.v2021_02_01.models.JobErrorDetails + :ivar job_type: The type of the job. Known values are: "Invalid", "ScanForUpdates", + "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer", "Backup", "Restore", + and "TriggerSupportPackage". + :vartype job_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.JobType + :ivar current_stage: Current stage of the update operation. Known values are: "Unknown", + "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", + "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", + "Success", "Failure", "RescanStarted", "RescanComplete", and "RescanFailed". + :vartype current_stage: str or ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateOperationStage + :ivar download_progress: The download progress. + :vartype download_progress: ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateDownloadProgress + :ivar install_progress: The install progress. + :vartype install_progress: ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateInstallProgress + :ivar total_refresh_errors: Total number of errors encountered during the refresh process. + :vartype total_refresh_errors: int + :ivar error_manifest_file: Local share/remote container relative path to the error manifest + file of the refresh. + :vartype error_manifest_file: str + :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. + :vartype refreshed_entity_id: str + :ivar folder: If only subfolders need to be refreshed, then the subfolder path inside the share + or container. (The path is empty if there are no subfolders.). + :vartype folder: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "error": {"readonly": True}, + "job_type": {"readonly": True}, + "current_stage": {"readonly": True}, + "download_progress": {"readonly": True}, + "install_progress": {"readonly": True}, + "total_refresh_errors": {"readonly": True}, + "error_manifest_file": {"readonly": True}, + "refreshed_entity_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "error": {"key": "error", "type": "JobErrorDetails"}, + "job_type": {"key": "properties.jobType", "type": "str"}, + "current_stage": {"key": "properties.currentStage", "type": "str"}, + "download_progress": {"key": "properties.downloadProgress", "type": "UpdateDownloadProgress"}, + "install_progress": {"key": "properties.installProgress", "type": "UpdateInstallProgress"}, + "total_refresh_errors": {"key": "properties.totalRefreshErrors", "type": "int"}, + "error_manifest_file": {"key": "properties.errorManifestFile", "type": "str"}, + "refreshed_entity_id": {"key": "properties.refreshedEntityId", "type": "str"}, + "folder": {"key": "properties.folder", "type": "str"}, + } + + def __init__(self, *, folder: Optional[str] = None, **kwargs): + """ + :keyword folder: If only subfolders need to be refreshed, then the subfolder path inside the + share or container. (The path is empty if there are no subfolders.). + :paramtype folder: str + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.status = None + self.start_time = None + self.end_time = None + self.percent_complete = None + self.error = None + self.job_type = None + self.current_stage = None + self.download_progress = None + self.install_progress = None + self.total_refresh_errors = None + self.error_manifest_file = None + self.refreshed_entity_id = None + self.folder = folder + + +class JobErrorDetails(_serialization.Model): + """The job error information containing the list of job errors. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar error_details: The error details. + :vartype error_details: list[~azure.mgmt.databoxedge.v2021_02_01.models.JobErrorItem] + :ivar code: The code intended for programmatic access. + :vartype code: str + :ivar message: The message that describes the error in detail. + :vartype message: str + """ + + _validation = { + "error_details": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + } + + _attribute_map = { + "error_details": {"key": "errorDetails", "type": "[JobErrorItem]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.error_details = None + self.code = None + self.message = None + + +class JobErrorItem(_serialization.Model): + """The job error items. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar recommendations: The recommended actions. + :vartype recommendations: list[str] + :ivar code: The code intended for programmatic access. + :vartype code: str + :ivar message: The message that describes the error in detail. + :vartype message: str + """ + + _validation = { + "recommendations": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + } + + _attribute_map = { + "recommendations": {"key": "recommendations", "type": "[str]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.recommendations = None + self.code = None + self.message = None + + +class KubernetesClusterInfo(_serialization.Model): + """Kubernetes cluster configuration. + + 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 etcd_info: Etcd configuration. + :vartype etcd_info: ~azure.mgmt.databoxedge.v2021_02_01.models.EtcdInfo + :ivar nodes: Kubernetes cluster nodes. + :vartype nodes: list[~azure.mgmt.databoxedge.v2021_02_01.models.NodeInfo] + :ivar version: Kubernetes cluster version. Required. + :vartype version: str + """ + + _validation = { + "etcd_info": {"readonly": True}, + "nodes": {"readonly": True}, + "version": {"required": True}, + } + + _attribute_map = { + "etcd_info": {"key": "etcdInfo", "type": "EtcdInfo"}, + "nodes": {"key": "nodes", "type": "[NodeInfo]"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__(self, *, version: str, **kwargs): + """ + :keyword version: Kubernetes cluster version. Required. + :paramtype version: str + """ + super().__init__(**kwargs) + self.etcd_info = None + self.nodes = None + self.version = version + + +class KubernetesIPConfiguration(_serialization.Model): + """Kubernetes node IP configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar port: Port of the Kubernetes node. + :vartype port: str + :ivar ip_address: IP address of the Kubernetes node. + :vartype ip_address: str + """ + + _validation = { + "port": {"readonly": True}, + } + + _attribute_map = { + "port": {"key": "port", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, + } + + def __init__(self, *, ip_address: Optional[str] = None, **kwargs): + """ + :keyword ip_address: IP address of the Kubernetes node. + :paramtype ip_address: str + """ + super().__init__(**kwargs) + self.port = None + self.ip_address = ip_address + + +class KubernetesRole(Role): # pylint: disable=too-many-instance-attributes + """The limited preview of Kubernetes Cluster Management from the Azure supports: + + + #. Using a simple turn-key option in Azure Portal, deploy a Kubernetes cluster on your Azure Stack Edge device. + #. Configure Kubernetes cluster running on your device with Arc enabled Kubernetes with a click of a button in the Azure Portal. + Azure Arc enables organizations to view, manage, and govern their on-premises Kubernetes clusters using the Azure Portal, command line tools, and APIs. + #. Easily configure Persistent Volumes using SMB and NFS shares for storing container data. + For more information, refer to the document here: https://databoxupdatepackages.blob.core.windows.net/documentation/Microsoft-Azure-Stack-Edge-K8-Cloud-Management-20210323.pdf + Or Demo: https://databoxupdatepackages.blob.core.windows.net/documentation/Microsoft-Azure-Stack-Edge-K8S-Cloud-Management-20210323.mp4 + By using this feature, you agree to the preview legal terms. See the https://azure.microsoft.com/en-us/support/legal/preview-supplemental-terms/. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleTypes + :ivar system_data: Role configured on ASE resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" and + "Linux". + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01.models.PlatformType + :ivar provisioning_state: State of Kubernetes deployment. Known values are: "Invalid", + "Creating", "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesState + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". + :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.HostPlatformType + :ivar kubernetes_cluster_info: Kubernetes cluster configuration. + :vartype kubernetes_cluster_info: + ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesClusterInfo + :ivar kubernetes_role_resources: Kubernetes role resources. + :vartype kubernetes_role_resources: + ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesRoleResources + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "host_platform_type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "kubernetes_cluster_info": {"key": "properties.kubernetesClusterInfo", "type": "KubernetesClusterInfo"}, + "kubernetes_role_resources": {"key": "properties.kubernetesRoleResources", "type": "KubernetesRoleResources"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, + } + + def __init__( + self, + *, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + kubernetes_cluster_info: Optional["_models.KubernetesClusterInfo"] = None, + kubernetes_role_resources: Optional["_models.KubernetesRoleResources"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, + **kwargs + ): + """ + :keyword host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" + and "Linux". + :paramtype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01.models.PlatformType + :keyword kubernetes_cluster_info: Kubernetes cluster configuration. + :paramtype kubernetes_cluster_info: + ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesClusterInfo + :keyword kubernetes_role_resources: Kubernetes role resources. + :paramtype kubernetes_role_resources: + ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesRoleResources + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "Kubernetes" + self.host_platform = host_platform + self.provisioning_state = None + self.host_platform_type = None + self.kubernetes_cluster_info = kubernetes_cluster_info + self.kubernetes_role_resources = kubernetes_role_resources + self.role_status = role_status + + +class KubernetesRoleCompute(_serialization.Model): + """Kubernetes role compute resource. + + 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 vm_profile: VM profile. Required. + :vartype vm_profile: str + :ivar memory_in_bytes: Memory in bytes. + :vartype memory_in_bytes: int + :ivar processor_count: Processor count. + :vartype processor_count: int + """ + + _validation = { + "vm_profile": {"required": True}, + "memory_in_bytes": {"readonly": True}, + "processor_count": {"readonly": True}, + } + + _attribute_map = { + "vm_profile": {"key": "vmProfile", "type": "str"}, + "memory_in_bytes": {"key": "memoryInBytes", "type": "int"}, + "processor_count": {"key": "processorCount", "type": "int"}, + } + + def __init__(self, *, vm_profile: str, **kwargs): + """ + :keyword vm_profile: VM profile. Required. + :paramtype vm_profile: str + """ + super().__init__(**kwargs) + self.vm_profile = vm_profile + self.memory_in_bytes = None + self.processor_count = None + + +class KubernetesRoleNetwork(_serialization.Model): + """Kubernetes role network resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cni_config: Cni configuration. + :vartype cni_config: ~azure.mgmt.databoxedge.v2021_02_01.models.CniConfig + :ivar load_balancer_config: Load balancer configuration. + :vartype load_balancer_config: ~azure.mgmt.databoxedge.v2021_02_01.models.LoadBalancerConfig + """ + + _validation = { + "cni_config": {"readonly": True}, + "load_balancer_config": {"readonly": True}, + } + + _attribute_map = { + "cni_config": {"key": "cniConfig", "type": "CniConfig"}, + "load_balancer_config": {"key": "loadBalancerConfig", "type": "LoadBalancerConfig"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.cni_config = None + self.load_balancer_config = None + + +class KubernetesRoleResources(_serialization.Model): + """Kubernetes role resources. + + 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 storage: Kubernetes role storage resource. + :vartype storage: ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesRoleStorage + :ivar compute: Kubernetes role compute resource. Required. + :vartype compute: ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesRoleCompute + :ivar network: Kubernetes role network resource. + :vartype network: ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesRoleNetwork + """ + + _validation = { + "compute": {"required": True}, + "network": {"readonly": True}, + } + + _attribute_map = { + "storage": {"key": "storage", "type": "KubernetesRoleStorage"}, + "compute": {"key": "compute", "type": "KubernetesRoleCompute"}, + "network": {"key": "network", "type": "KubernetesRoleNetwork"}, + } + + def __init__( + self, + *, + compute: "_models.KubernetesRoleCompute", + storage: Optional["_models.KubernetesRoleStorage"] = None, + **kwargs + ): + """ + :keyword storage: Kubernetes role storage resource. + :paramtype storage: ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesRoleStorage + :keyword compute: Kubernetes role compute resource. Required. + :paramtype compute: ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesRoleCompute + """ + super().__init__(**kwargs) + self.storage = storage + self.compute = compute + self.network = None + + +class KubernetesRoleStorage(_serialization.Model): + """Kubernetes role storage resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar storage_classes: Kubernetes storage class info. + :vartype storage_classes: + list[~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesRoleStorageClassInfo] + :ivar endpoints: Mount points of shares in role(s). + :vartype endpoints: list[~azure.mgmt.databoxedge.v2021_02_01.models.MountPointMap] + """ + + _validation = { + "storage_classes": {"readonly": True}, + } + + _attribute_map = { + "storage_classes": {"key": "storageClasses", "type": "[KubernetesRoleStorageClassInfo]"}, + "endpoints": {"key": "endpoints", "type": "[MountPointMap]"}, + } + + def __init__(self, *, endpoints: Optional[List["_models.MountPointMap"]] = None, **kwargs): + """ + :keyword endpoints: Mount points of shares in role(s). + :paramtype endpoints: list[~azure.mgmt.databoxedge.v2021_02_01.models.MountPointMap] + """ + super().__init__(**kwargs) + self.storage_classes = None + self.endpoints = endpoints + + +class KubernetesRoleStorageClassInfo(_serialization.Model): + """Kubernetes storage class info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Storage class name. + :vartype name: str + :ivar type: Storage class type. + :vartype type: str + :ivar posix_compliant: If provisioned storage is posix compliant. Known values are: "Invalid", + "Enabled", and "Disabled". + :vartype posix_compliant: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.PosixComplianceStatus + """ + + _validation = { + "name": {"readonly": True}, + "type": {"readonly": True}, + "posix_compliant": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "posix_compliant": {"key": "posixCompliant", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.type = None + self.posix_compliant = None + + +class LoadBalancerConfig(_serialization.Model): + """Load balancer configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: Load balancer type. + :vartype type: str + :ivar version: Load balancer version. + :vartype version: str + """ + + _validation = { + "type": {"readonly": True}, + "version": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.type = None + self.version = None + + +class MECRole(Role): + """MEC role. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleTypes + :ivar system_data: Role configured on ASE resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar connection_string: Activation key of the MEC. + :vartype connection_string: + ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + :ivar controller_endpoint: Controller Endpoint. + :vartype controller_endpoint: str + :ivar resource_unique_id: Unique Id of the Resource. + :vartype resource_unique_id: str + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "connection_string": {"key": "properties.connectionString", "type": "AsymmetricEncryptedSecret"}, + "controller_endpoint": {"key": "properties.controllerEndpoint", "type": "str"}, + "resource_unique_id": {"key": "properties.resourceUniqueId", "type": "str"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, + } + + def __init__( + self, + *, + connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, + controller_endpoint: Optional[str] = None, + resource_unique_id: Optional[str] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, + **kwargs + ): + """ + :keyword connection_string: Activation key of the MEC. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + :keyword controller_endpoint: Controller Endpoint. + :paramtype controller_endpoint: str + :keyword resource_unique_id: Unique Id of the Resource. + :paramtype resource_unique_id: str + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "MEC" + self.connection_string = connection_string + self.controller_endpoint = controller_endpoint + self.resource_unique_id = resource_unique_id + self.role_status = role_status + + +class MetricConfiguration(_serialization.Model): + """Metric configuration. + + All required parameters must be populated in order to send to Azure. + + :ivar resource_id: The Resource ID on which the metrics should be pushed. Required. + :vartype resource_id: str + :ivar mdm_account: The MDM account to which the counters should be pushed. + :vartype mdm_account: str + :ivar metric_name_space: The MDM namespace to which the counters should be pushed. This is + required if MDMAccount is specified. + :vartype metric_name_space: str + :ivar counter_sets: Host name for the IoT hub associated to the device. Required. + :vartype counter_sets: list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricCounterSet] + """ + + _validation = { + "resource_id": {"required": True}, + "counter_sets": {"required": True}, + } + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "mdm_account": {"key": "mdmAccount", "type": "str"}, + "metric_name_space": {"key": "metricNameSpace", "type": "str"}, + "counter_sets": {"key": "counterSets", "type": "[MetricCounterSet]"}, + } + + def __init__( + self, + *, + resource_id: str, + counter_sets: List["_models.MetricCounterSet"], + mdm_account: Optional[str] = None, + metric_name_space: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_id: The Resource ID on which the metrics should be pushed. Required. + :paramtype resource_id: str + :keyword mdm_account: The MDM account to which the counters should be pushed. + :paramtype mdm_account: str + :keyword metric_name_space: The MDM namespace to which the counters should be pushed. This is + required if MDMAccount is specified. + :paramtype metric_name_space: str + :keyword counter_sets: Host name for the IoT hub associated to the device. Required. + :paramtype counter_sets: list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricCounterSet] + """ + super().__init__(**kwargs) + self.resource_id = resource_id + self.mdm_account = mdm_account + self.metric_name_space = metric_name_space + self.counter_sets = counter_sets + + +class MetricCounter(_serialization.Model): + """The metric counter. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The counter name. Required. + :vartype name: str + :ivar instance: The instance from which counter should be collected. + :vartype instance: str + :ivar dimension_filter: The dimension filter. + :vartype dimension_filter: list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricDimension] + :ivar additional_dimensions: The additional dimensions to be added to metric. + :vartype additional_dimensions: + list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricDimension] + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "instance": {"key": "instance", "type": "str"}, + "dimension_filter": {"key": "dimensionFilter", "type": "[MetricDimension]"}, + "additional_dimensions": {"key": "additionalDimensions", "type": "[MetricDimension]"}, + } + + def __init__( + self, + *, + name: str, + instance: Optional[str] = None, + dimension_filter: Optional[List["_models.MetricDimension"]] = None, + additional_dimensions: Optional[List["_models.MetricDimension"]] = None, + **kwargs + ): + """ + :keyword name: The counter name. Required. + :paramtype name: str + :keyword instance: The instance from which counter should be collected. + :paramtype instance: str + :keyword dimension_filter: The dimension filter. + :paramtype dimension_filter: list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricDimension] + :keyword additional_dimensions: The additional dimensions to be added to metric. + :paramtype additional_dimensions: + list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricDimension] + """ + super().__init__(**kwargs) + self.name = name + self.instance = instance + self.dimension_filter = dimension_filter + self.additional_dimensions = additional_dimensions + + +class MetricCounterSet(_serialization.Model): + """The metric counter set. + + All required parameters must be populated in order to send to Azure. + + :ivar counters: The counters that should be collected in this set. Required. + :vartype counters: list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricCounter] + """ + + _validation = { + "counters": {"required": True}, + } + + _attribute_map = { + "counters": {"key": "counters", "type": "[MetricCounter]"}, + } + + def __init__(self, *, counters: List["_models.MetricCounter"], **kwargs): + """ + :keyword counters: The counters that should be collected in this set. Required. + :paramtype counters: list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricCounter] + """ + super().__init__(**kwargs) + self.counters = counters + + +class MetricDimension(_serialization.Model): + """The metric dimension. + + All required parameters must be populated in order to send to Azure. + + :ivar source_type: The dimension type. Required. + :vartype source_type: str + :ivar source_name: The dimension value. Required. + :vartype source_name: str + """ + + _validation = { + "source_type": {"required": True}, + "source_name": {"required": True}, + } + + _attribute_map = { + "source_type": {"key": "sourceType", "type": "str"}, + "source_name": {"key": "sourceName", "type": "str"}, + } + + def __init__(self, *, source_type: str, source_name: str, **kwargs): + """ + :keyword source_type: The dimension type. Required. + :paramtype source_type: str + :keyword source_name: The dimension value. Required. + :paramtype source_name: str + """ + super().__init__(**kwargs) + self.source_type = source_type + self.source_name = source_name + + +class MetricDimensionV1(_serialization.Model): + """Metric Dimension v1. + + :ivar name: Name of the metrics dimension. + :vartype name: str + :ivar display_name: Display name of the metrics dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + to_be_exported_for_shoebox: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Name of the metrics dimension. + :paramtype name: str + :keyword display_name: Display name of the metrics dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.to_be_exported_for_shoebox = to_be_exported_for_shoebox + + +class MetricSpecificationV1(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Metric specification version 1. + + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Description of the metric to be displayed. + :vartype display_description: str + :ivar unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :vartype unit: str or ~azure.mgmt.databoxedge.v2021_02_01.models.MetricUnit + :ivar aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :vartype aggregation_type: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.MetricAggregationType + :ivar dimensions: Metric dimensions, other than default dimension which is resource. + :vartype dimensions: list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricDimensionV1] + :ivar fill_gap_with_zero: Set true to fill the gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar category: Metric category. Known values are: "Capacity" and "Transaction". + :vartype category: str or ~azure.mgmt.databoxedge.v2021_02_01.models.MetricCategory + :ivar resource_id_dimension_name_override: Resource name override. + :vartype resource_id_dimension_name_override: str + :ivar supported_time_grain_types: Support granularity of metrics. + :vartype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2021_02_01.models.TimeGrain] + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2021_02_01.models.MetricAggregationType] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimensionV1]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, + dimensions: Optional[List["_models.MetricDimensionV1"]] = None, + fill_gap_with_zero: Optional[bool] = None, + category: Optional[Union[str, "_models.MetricCategory"]] = None, + resource_id_dimension_name_override: Optional[str] = None, + supported_time_grain_types: Optional[List[Union[str, "_models.TimeGrain"]]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, + **kwargs + ): + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Description of the metric to be displayed. + :paramtype display_description: str + :keyword unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :paramtype unit: str or ~azure.mgmt.databoxedge.v2021_02_01.models.MetricUnit + :keyword aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :paramtype aggregation_type: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.MetricAggregationType + :keyword dimensions: Metric dimensions, other than default dimension which is resource. + :paramtype dimensions: list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricDimensionV1] + :keyword fill_gap_with_zero: Set true to fill the gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: Metric category. Known values are: "Capacity" and "Transaction". + :paramtype category: str or ~azure.mgmt.databoxedge.v2021_02_01.models.MetricCategory + :keyword resource_id_dimension_name_override: Resource name override. + :paramtype resource_id_dimension_name_override: str + :keyword supported_time_grain_types: Support granularity of metrics. + :paramtype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2021_02_01.models.TimeGrain] + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2021_02_01.models.MetricAggregationType] + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.aggregation_type = aggregation_type + self.dimensions = dimensions + self.fill_gap_with_zero = fill_gap_with_zero + self.category = category + self.resource_id_dimension_name_override = resource_id_dimension_name_override + self.supported_time_grain_types = supported_time_grain_types + self.supported_aggregation_types = supported_aggregation_types + + +class MonitoringMetricConfiguration(ARMBaseModel): + """The metric setting details for the role. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: MonitoringConfiguration on ASE device. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar metric_configurations: The metrics configuration details. Required. + :vartype metric_configurations: + list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricConfiguration] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "metric_configurations": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "metric_configurations": {"key": "properties.metricConfigurations", "type": "[MetricConfiguration]"}, + } + + def __init__(self, *, metric_configurations: List["_models.MetricConfiguration"], **kwargs): + """ + :keyword metric_configurations: The metrics configuration details. Required. + :paramtype metric_configurations: + list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricConfiguration] + """ + super().__init__(**kwargs) + self.system_data = None + self.metric_configurations = metric_configurations + + +class MonitoringMetricConfigurationList(_serialization.Model): + """Collection of metric configurations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of metric configurations. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[MonitoringMetricConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class MountPointMap(_serialization.Model): + """The share mount point. + + 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 share_id: ID of the share mounted to the role VM. Required. + :vartype share_id: str + :ivar role_id: ID of the role to which share is mounted. + :vartype role_id: str + :ivar mount_point: Mount point for the share. + :vartype mount_point: str + :ivar mount_type: Mounting type. Known values are: "Volume" and "HostPath". + :vartype mount_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.MountType + :ivar role_type: Role type. Known values are: "IOT", "ASA", "Functions", "Cognitive", "MEC", + "CloudEdgeManagement", and "Kubernetes". + :vartype role_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.RoleTypes + """ + + _validation = { + "share_id": {"required": True}, + "role_id": {"readonly": True}, + "mount_point": {"readonly": True}, + "mount_type": {"readonly": True}, + "role_type": {"readonly": True}, + } + + _attribute_map = { + "share_id": {"key": "shareId", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "mount_point": {"key": "mountPoint", "type": "str"}, + "mount_type": {"key": "mountType", "type": "str"}, + "role_type": {"key": "roleType", "type": "str"}, + } + + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: ID of the share mounted to the role VM. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) + self.share_id = share_id + self.role_id = None + self.mount_point = None + self.mount_type = None + self.role_type = None + + +class NetworkAdapter(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Represents the networkAdapter on a device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar adapter_id: Instance ID of network adapter. + :vartype adapter_id: str + :ivar adapter_position: Hardware position of network adapter. + :vartype adapter_position: ~azure.mgmt.databoxedge.v2021_02_01.models.NetworkAdapterPosition + :ivar index: Logical index of the adapter. + :vartype index: int + :ivar node_id: Node ID of the network adapter. + :vartype node_id: str + :ivar network_adapter_name: Network adapter name. + :vartype network_adapter_name: str + :ivar label: Hardware label for the adapter. + :vartype label: str + :ivar mac_address: MAC address. + :vartype mac_address: str + :ivar link_speed: Link speed. + :vartype link_speed: int + :ivar status: Value indicating whether this adapter is valid. Known values are: "Inactive" and + "Active". + :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.NetworkAdapterStatus + :ivar rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :vartype rdma_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.NetworkAdapterRDMAStatus + :ivar dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :vartype dhcp_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.NetworkAdapterDHCPStatus + :ivar ipv4_configuration: The IPv4 configuration of the network adapter. + :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2021_02_01.models.Ipv4Config + :ivar ipv6_configuration: The IPv6 configuration of the network adapter. + :vartype ipv6_configuration: ~azure.mgmt.databoxedge.v2021_02_01.models.Ipv6Config + :ivar ipv6_link_local_address: The IPv6 local address. + :vartype ipv6_link_local_address: str + :ivar dns_servers: The list of DNS Servers of the device. + :vartype dns_servers: list[str] + """ + + _validation = { + "adapter_id": {"readonly": True}, + "adapter_position": {"readonly": True}, + "index": {"readonly": True}, + "node_id": {"readonly": True}, + "network_adapter_name": {"readonly": True}, + "label": {"readonly": True}, + "mac_address": {"readonly": True}, + "link_speed": {"readonly": True}, + "status": {"readonly": True}, + "ipv4_configuration": {"readonly": True}, + "ipv6_configuration": {"readonly": True}, + "ipv6_link_local_address": {"readonly": True}, + "dns_servers": {"readonly": True}, + } + + _attribute_map = { + "adapter_id": {"key": "adapterId", "type": "str"}, + "adapter_position": {"key": "adapterPosition", "type": "NetworkAdapterPosition"}, + "index": {"key": "index", "type": "int"}, + "node_id": {"key": "nodeId", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "mac_address": {"key": "macAddress", "type": "str"}, + "link_speed": {"key": "linkSpeed", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "rdma_status": {"key": "rdmaStatus", "type": "str"}, + "dhcp_status": {"key": "dhcpStatus", "type": "str"}, + "ipv4_configuration": {"key": "ipv4Configuration", "type": "Ipv4Config"}, + "ipv6_configuration": {"key": "ipv6Configuration", "type": "Ipv6Config"}, + "ipv6_link_local_address": {"key": "ipv6LinkLocalAddress", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, + } + + def __init__( + self, + *, + rdma_status: Optional[Union[str, "_models.NetworkAdapterRDMAStatus"]] = None, + dhcp_status: Optional[Union[str, "_models.NetworkAdapterDHCPStatus"]] = None, + **kwargs + ): + """ + :keyword rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :paramtype rdma_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.NetworkAdapterRDMAStatus + :keyword dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :paramtype dhcp_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.NetworkAdapterDHCPStatus + """ + super().__init__(**kwargs) + self.adapter_id = None + self.adapter_position = None + self.index = None + self.node_id = None + self.network_adapter_name = None + self.label = None + self.mac_address = None + self.link_speed = None + self.status = None + self.rdma_status = rdma_status + self.dhcp_status = dhcp_status + self.ipv4_configuration = None + self.ipv6_configuration = None + self.ipv6_link_local_address = None + self.dns_servers = None + + +class NetworkAdapterPosition(_serialization.Model): + """The network adapter position. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar network_group: The network group. Known values are: "None", "NonRDMA", and "RDMA". + :vartype network_group: str or ~azure.mgmt.databoxedge.v2021_02_01.models.NetworkGroup + :ivar port: The port. + :vartype port: int + """ + + _validation = { + "network_group": {"readonly": True}, + "port": {"readonly": True}, + } + + _attribute_map = { + "network_group": {"key": "networkGroup", "type": "str"}, + "port": {"key": "port", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.network_group = None + self.port = None + + +class NetworkSettings(ARMBaseModel): + """The network settings of a device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: NetworkSettings on ASE device. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar network_adapters: The network adapter list on the device. + :vartype network_adapters: list[~azure.mgmt.databoxedge.v2021_02_01.models.NetworkAdapter] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "network_adapters": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "network_adapters": {"key": "properties.networkAdapters", "type": "[NetworkAdapter]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.system_data = None + self.network_adapters = None + + +class Node(ARMBaseModel): + """Represents a single node in a Data box Edge/Gateway device + Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node + Multi-node Edge devices will have more than 1 nodes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar node_status: The current status of the individual node. Known values are: "Unknown", + "Up", "Down", "Rebooting", and "ShuttingDown". + :vartype node_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.NodeStatus + :ivar node_chassis_serial_number: Serial number of the Chassis. + :vartype node_chassis_serial_number: str + :ivar node_serial_number: Serial number of the individual node. + :vartype node_serial_number: str + :ivar node_display_name: Display Name of the individual node. + :vartype node_display_name: str + :ivar node_friendly_software_version: Friendly software version name that is currently + installed on the node. + :vartype node_friendly_software_version: str + :ivar node_hcs_version: HCS version that is currently installed on the node. + :vartype node_hcs_version: str + :ivar node_instance_id: Guid instance id of the node. + :vartype node_instance_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "node_status": {"readonly": True}, + "node_chassis_serial_number": {"readonly": True}, + "node_serial_number": {"readonly": True}, + "node_display_name": {"readonly": True}, + "node_friendly_software_version": {"readonly": True}, + "node_hcs_version": {"readonly": True}, + "node_instance_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "node_status": {"key": "properties.nodeStatus", "type": "str"}, + "node_chassis_serial_number": {"key": "properties.nodeChassisSerialNumber", "type": "str"}, + "node_serial_number": {"key": "properties.nodeSerialNumber", "type": "str"}, + "node_display_name": {"key": "properties.nodeDisplayName", "type": "str"}, + "node_friendly_software_version": {"key": "properties.nodeFriendlySoftwareVersion", "type": "str"}, + "node_hcs_version": {"key": "properties.nodeHcsVersion", "type": "str"}, + "node_instance_id": {"key": "properties.nodeInstanceId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.node_status = None + self.node_chassis_serial_number = None + self.node_serial_number = None + self.node_display_name = None + self.node_friendly_software_version = None + self.node_hcs_version = None + self.node_instance_id = None + + +class NodeInfo(_serialization.Model): + """Kubernetes node info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Node name. + :vartype name: str + :ivar type: Node type - Master/Worker. Known values are: "Invalid", "Master", and "Worker". + :vartype type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesNodeType + :ivar ip_configuration: IP Configuration of the Kubernetes node. + :vartype ip_configuration: + list[~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesIPConfiguration] + """ + + _validation = { + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "ip_configuration": {"key": "ipConfiguration", "type": "[KubernetesIPConfiguration]"}, + } + + def __init__(self, *, ip_configuration: Optional[List["_models.KubernetesIPConfiguration"]] = None, **kwargs): + """ + :keyword ip_configuration: IP Configuration of the Kubernetes node. + :paramtype ip_configuration: + list[~azure.mgmt.databoxedge.v2021_02_01.models.KubernetesIPConfiguration] + """ + super().__init__(**kwargs) + self.name = None + self.type = None + self.ip_configuration = ip_configuration + + +class NodeList(_serialization.Model): + """Collection of Nodes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of Nodes. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Node] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Node]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class Operation(_serialization.Model): + """Operations. + + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Is data action. + :vartype is_data_action: bool + :ivar display: Properties displayed for the operation. + :vartype display: ~azure.mgmt.databoxedge.v2021_02_01.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar service_specification: Service specification. + :vartype service_specification: ~azure.mgmt.databoxedge.v2021_02_01.models.ServiceSpecification + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, + **kwargs + ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Is data action. + :paramtype is_data_action: bool + :keyword display: Properties displayed for the operation. + :paramtype display: ~azure.mgmt.databoxedge.v2021_02_01.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword service_specification: Service specification. + :paramtype service_specification: + ~azure.mgmt.databoxedge.v2021_02_01.models.ServiceSpecification + """ + super().__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.origin = origin + self.service_specification = service_specification + + +class OperationDisplay(_serialization.Model): + """Operation display properties. + + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: The type of resource in which the operation is performed. + :vartype resource: str + :ivar operation: Operation to be performed on the resource. + :vartype operation: str + :ivar description: Description of the operation to be performed. + :vartype description: str + """ + + _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, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: The type of resource in which the operation is performed. + :paramtype resource: str + :keyword operation: Operation to be performed on the resource. + :paramtype operation: str + :keyword description: Description of the operation to be performed. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationsList(_serialization.Model): + """The list of operations used for the discovery of available provider operations. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The value. Required. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Operation] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The value. Required. + :paramtype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Operation] + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Order(ARMBaseModel): # pylint: disable=too-many-instance-attributes + """The order details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: Order configured on ASE resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar contact_information: The contact details. + :vartype contact_information: ~azure.mgmt.databoxedge.v2021_02_01.models.ContactDetails + :ivar shipping_address: The shipping address. + :vartype shipping_address: ~azure.mgmt.databoxedge.v2021_02_01.models.Address + :ivar current_status: Current status of the order. + :vartype current_status: ~azure.mgmt.databoxedge.v2021_02_01.models.OrderStatus + :ivar order_history: List of status changes in the order. + :vartype order_history: list[~azure.mgmt.databoxedge.v2021_02_01.models.OrderStatus] + :ivar serial_number: Serial number of the device. + :vartype serial_number: str + :ivar delivery_tracking_info: Tracking information for the package delivered to the customer + whether it has an original or a replacement device. + :vartype delivery_tracking_info: list[~azure.mgmt.databoxedge.v2021_02_01.models.TrackingInfo] + :ivar return_tracking_info: Tracking information for the package returned from the customer + whether it has an original or a replacement device. + :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2021_02_01.models.TrackingInfo] + :ivar shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :vartype shipment_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShipmentType + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "current_status": {"readonly": True}, + "order_history": {"readonly": True}, + "serial_number": {"readonly": True}, + "delivery_tracking_info": {"readonly": True}, + "return_tracking_info": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "contact_information": {"key": "properties.contactInformation", "type": "ContactDetails"}, + "shipping_address": {"key": "properties.shippingAddress", "type": "Address"}, + "current_status": {"key": "properties.currentStatus", "type": "OrderStatus"}, + "order_history": {"key": "properties.orderHistory", "type": "[OrderStatus]"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "delivery_tracking_info": {"key": "properties.deliveryTrackingInfo", "type": "[TrackingInfo]"}, + "return_tracking_info": {"key": "properties.returnTrackingInfo", "type": "[TrackingInfo]"}, + "shipment_type": {"key": "properties.shipmentType", "type": "str"}, + } + + def __init__( + self, + *, + contact_information: Optional["_models.ContactDetails"] = None, + shipping_address: Optional["_models.Address"] = None, + shipment_type: Optional[Union[str, "_models.ShipmentType"]] = None, + **kwargs + ): + """ + :keyword contact_information: The contact details. + :paramtype contact_information: ~azure.mgmt.databoxedge.v2021_02_01.models.ContactDetails + :keyword shipping_address: The shipping address. + :paramtype shipping_address: ~azure.mgmt.databoxedge.v2021_02_01.models.Address + :keyword shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :paramtype shipment_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShipmentType + """ + super().__init__(**kwargs) + self.system_data = None + self.contact_information = contact_information + self.shipping_address = shipping_address + self.current_status = None + self.order_history = None + self.serial_number = None + self.delivery_tracking_info = None + self.return_tracking_info = None + self.shipment_type = shipment_type + + +class OrderList(_serialization.Model): + """List of order entities. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of orders. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Order] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Order]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class OrderStatus(_serialization.Model): + """Represents a single status change. + + 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 status: Status of the order as per the allowed status types. Required. Known values are: + "Untracked", "AwaitingFulfillment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.OrderState + :ivar update_date_time: Time of status update. + :vartype update_date_time: ~datetime.datetime + :ivar comments: Comments related to this status change. + :vartype comments: str + :ivar tracking_information: Tracking information related to the state in the ordering flow. + :vartype tracking_information: ~azure.mgmt.databoxedge.v2021_02_01.models.TrackingInfo + :ivar additional_order_details: Dictionary to hold generic information which is not stored + by the already existing properties. + :vartype additional_order_details: dict[str, str] + """ + + _validation = { + "status": {"required": True}, + "update_date_time": {"readonly": True}, + "tracking_information": {"readonly": True}, + "additional_order_details": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + "comments": {"key": "comments", "type": "str"}, + "tracking_information": {"key": "trackingInformation", "type": "TrackingInfo"}, + "additional_order_details": {"key": "additionalOrderDetails", "type": "{str}"}, + } + + def __init__(self, *, status: Union[str, "_models.OrderState"], comments: Optional[str] = None, **kwargs): + """ + :keyword status: Status of the order as per the allowed status types. Required. Known values + are: "Untracked", "AwaitingFulfillment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :paramtype status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.OrderState + :keyword comments: Comments related to this status change. + :paramtype comments: str + """ + super().__init__(**kwargs) + self.status = status + self.update_date_time = None + self.comments = comments + self.tracking_information = None + self.additional_order_details = None + + +class PeriodicTimerEventTrigger(Trigger): + """Trigger details. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: Trigger in DataBoxEdge Resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01.models.TriggerEventType + :ivar source_info: Periodic timer details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2021_02_01.models.PeriodicTimerSourceInfo + :ivar sink_info: Role Sink information. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2021_02_01.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against + its usage. For example, if a periodic timer trigger is intended for certain specific IoT + modules in the device, the tag can be the name or the image URL of the module. + :vartype custom_context_tag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "PeriodicTimerSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, + } + + def __init__( + self, + *, + source_info: "_models.PeriodicTimerSourceInfo", + sink_info: "_models.RoleSinkInfo", + custom_context_tag: Optional[str] = None, + **kwargs + ): + """ + :keyword source_info: Periodic timer details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2021_02_01.models.PeriodicTimerSourceInfo + :keyword sink_info: Role Sink information. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2021_02_01.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "PeriodicTimerEvent" + self.source_info = source_info + self.sink_info = sink_info + self.custom_context_tag = custom_context_tag + + +class PeriodicTimerSourceInfo(_serialization.Model): + """Periodic timer event source. + + All required parameters must be populated in order to send to Azure. + + :ivar start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :vartype start_time: ~datetime.datetime + :ivar schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :vartype schedule: str + :ivar topic: Topic where periodic events are published to IoT device. + :vartype topic: str + """ + + _validation = { + "start_time": {"required": True}, + "schedule": {"required": True}, + } + + _attribute_map = { + "start_time": {"key": "startTime", "type": "iso-8601"}, + "schedule": {"key": "schedule", "type": "str"}, + "topic": {"key": "topic", "type": "str"}, + } + + def __init__(self, *, start_time: datetime.datetime, schedule: str, topic: Optional[str] = None, **kwargs): + """ + :keyword start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :paramtype start_time: ~datetime.datetime + :keyword schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :paramtype schedule: str + :keyword topic: Topic where periodic events are published to IoT device. + :paramtype topic: str + """ + super().__init__(**kwargs) + self.start_time = start_time + self.schedule = schedule + self.topic = topic + + +class RefreshDetails(_serialization.Model): + """Fields for tracking refresh job on the share or container. + + :ivar in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + container, this field indicates the ARM resource ID of that job. The field is empty if no job + is in progress. + :vartype in_progress_refresh_job_id: str + :ivar last_completed_refresh_job_time_in_utc: Indicates the completed time for the last refresh + job on this particular share or container, if any.This could be a failed job or a successful + job. + :vartype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :ivar error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share or container, if any. This could be a failed job or a successful + job. + :vartype error_manifest_file: str + :ivar last_job: Indicates the id of the last refresh job on this particular share or + container,if any. This could be a failed job or a successful job. + :vartype last_job: str + """ + + _attribute_map = { + "in_progress_refresh_job_id": {"key": "inProgressRefreshJobId", "type": "str"}, + "last_completed_refresh_job_time_in_utc": {"key": "lastCompletedRefreshJobTimeInUTC", "type": "iso-8601"}, + "error_manifest_file": {"key": "errorManifestFile", "type": "str"}, + "last_job": {"key": "lastJob", "type": "str"}, + } + + def __init__( + self, + *, + in_progress_refresh_job_id: Optional[str] = None, + last_completed_refresh_job_time_in_utc: Optional[datetime.datetime] = None, + error_manifest_file: Optional[str] = None, + last_job: Optional[str] = None, + **kwargs + ): + """ + :keyword in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + container, this field indicates the ARM resource ID of that job. The field is empty if no job + is in progress. + :paramtype in_progress_refresh_job_id: str + :keyword last_completed_refresh_job_time_in_utc: Indicates the completed time for the last + refresh job on this particular share or container, if any.This could be a failed job or a + successful job. + :paramtype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :keyword error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share or container, if any. This could be a failed job or a successful + job. + :paramtype error_manifest_file: str + :keyword last_job: Indicates the id of the last refresh job on this particular share or + container,if any. This could be a failed job or a successful job. + :paramtype last_job: str + """ + super().__init__(**kwargs) + self.in_progress_refresh_job_id = in_progress_refresh_job_id + self.last_completed_refresh_job_time_in_utc = last_completed_refresh_job_time_in_utc + self.error_manifest_file = error_manifest_file + self.last_job = last_job + + +class RemoteSupportSettings(_serialization.Model): + """RemoteApplicationType for which remote support settings is being modified. + + :ivar remote_application_type: Remote application type. Known values are: "Powershell", "WAC", + "LocalUI", and "AllApplications". + :vartype remote_application_type: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.RemoteApplicationType + :ivar access_level: Access level allowed for this remote application type. Known values are: + "None", "ReadOnly", "ReadWrite", and "FullAccess". + :vartype access_level: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AccessLevel + :ivar expiration_time_stamp_in_utc: Expiration time stamp. + :vartype expiration_time_stamp_in_utc: ~datetime.datetime + """ + + _attribute_map = { + "remote_application_type": {"key": "remoteApplicationType", "type": "str"}, + "access_level": {"key": "accessLevel", "type": "str"}, + "expiration_time_stamp_in_utc": {"key": "expirationTimeStampInUTC", "type": "iso-8601"}, + } + + def __init__( + self, + *, + remote_application_type: Optional[Union[str, "_models.RemoteApplicationType"]] = None, + access_level: Optional[Union[str, "_models.AccessLevel"]] = None, + expiration_time_stamp_in_utc: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword remote_application_type: Remote application type. Known values are: "Powershell", + "WAC", "LocalUI", and "AllApplications". + :paramtype remote_application_type: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.RemoteApplicationType + :keyword access_level: Access level allowed for this remote application type. Known values are: + "None", "ReadOnly", "ReadWrite", and "FullAccess". + :paramtype access_level: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AccessLevel + :keyword expiration_time_stamp_in_utc: Expiration time stamp. + :paramtype expiration_time_stamp_in_utc: ~datetime.datetime + """ + super().__init__(**kwargs) + self.remote_application_type = remote_application_type + self.access_level = access_level + self.expiration_time_stamp_in_utc = expiration_time_stamp_in_utc + + +class ResourceIdentity(_serialization.Model): + """Msi identity details of the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :vartype type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.MsiIdentityType + :ivar principal_id: Service Principal Id backing the Msi. + :vartype principal_id: str + :ivar tenant_id: Home Tenant Id. + :vartype tenant_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.MsiIdentityType"]] = None, **kwargs): + """ + :keyword type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :paramtype type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.MsiIdentityType + """ + super().__init__(**kwargs) + self.type = type + self.principal_id = None + self.tenant_id = None + + +class ResourceMoveDetails(_serialization.Model): + """Fields for tracking resource move. + + :ivar operation_in_progress: Denotes whether move operation is in progress. Known values are: + "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :vartype operation_in_progress: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.ResourceMoveStatus + :ivar operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + finish. + :vartype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + """ + + _attribute_map = { + "operation_in_progress": {"key": "operationInProgress", "type": "str"}, + "operation_in_progress_lock_timeout_in_utc": {"key": "operationInProgressLockTimeoutInUTC", "type": "iso-8601"}, + } + + def __init__( + self, + *, + operation_in_progress: Optional[Union[str, "_models.ResourceMoveStatus"]] = None, + operation_in_progress_lock_timeout_in_utc: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword operation_in_progress: Denotes whether move operation is in progress. Known values + are: "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :paramtype operation_in_progress: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.ResourceMoveStatus + :keyword operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + finish. + :paramtype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + """ + super().__init__(**kwargs) + self.operation_in_progress = operation_in_progress + self.operation_in_progress_lock_timeout_in_utc = operation_in_progress_lock_timeout_in_utc + + +class ResourceTypeSku(_serialization.Model): + """Resource type Sku object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_type: The resource type. + :vartype resource_type: str + :ivar skus: The skus. + :vartype skus: list[~azure.mgmt.databoxedge.v2021_02_01.models.SkuInformation] + """ + + _validation = { + "resource_type": {"readonly": True}, + "skus": {"readonly": True}, + } + + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "skus": {"key": "skus", "type": "[SkuInformation]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.resource_type = None + self.skus = None + + +class RoleList(_serialization.Model): + """Collection of all the roles on the Data Box Edge device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The Value. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Role] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Role]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class RoleSinkInfo(_serialization.Model): + """Compute role against which events will be raised. + + All required parameters must be populated in order to send to Azure. + + :ivar role_id: Compute role ID. Required. + :vartype role_id: str + """ + + _validation = { + "role_id": {"required": True}, + } + + _attribute_map = { + "role_id": {"key": "roleId", "type": "str"}, + } + + def __init__(self, *, role_id: str, **kwargs): + """ + :keyword role_id: Compute role ID. Required. + :paramtype role_id: str + """ + super().__init__(**kwargs) + self.role_id = role_id + + +class Secret(_serialization.Model): + """Holds device secret either as a KeyVault reference or as an encrypted value. + + :ivar encrypted_secret: Encrypted (using device public key) secret value. + :vartype encrypted_secret: ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + :ivar key_vault_id: Id of the Key-Vault where secret is stored (ex: + secrets/AuthClientSecret/82ef4346187a4033a10d629cde07d740). + :vartype key_vault_id: str + """ + + _attribute_map = { + "encrypted_secret": {"key": "encryptedSecret", "type": "AsymmetricEncryptedSecret"}, + "key_vault_id": {"key": "keyVaultId", "type": "str"}, + } + + def __init__( + self, + *, + encrypted_secret: Optional["_models.AsymmetricEncryptedSecret"] = None, + key_vault_id: Optional[str] = None, + **kwargs + ): + """ + :keyword encrypted_secret: Encrypted (using device public key) secret value. + :paramtype encrypted_secret: + ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + :keyword key_vault_id: Id of the Key-Vault where secret is stored (ex: + secrets/AuthClientSecret/82ef4346187a4033a10d629cde07d740). + :paramtype key_vault_id: str + """ + super().__init__(**kwargs) + self.encrypted_secret = encrypted_secret + self.key_vault_id = key_vault_id + + +class SecuritySettings(ARMBaseModel): + """The security settings of a device. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :vartype device_admin_password: + ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "device_admin_password": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_admin_password": {"key": "properties.deviceAdminPassword", "type": "AsymmetricEncryptedSecret"}, + } + + def __init__(self, *, device_admin_password: "_models.AsymmetricEncryptedSecret", **kwargs): + """ + :keyword device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :paramtype device_admin_password: + ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) + self.device_admin_password = device_admin_password + + +class ServiceSpecification(_serialization.Model): + """Service specification. + + :ivar metric_specifications: Metric specification as defined by shoebox. + :vartype metric_specifications: + list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricSpecificationV1] + """ + + _attribute_map = { + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecificationV1]"}, + } + + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecificationV1"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specification as defined by shoebox. + :paramtype metric_specifications: + list[~azure.mgmt.databoxedge.v2021_02_01.models.MetricSpecificationV1] + """ + super().__init__(**kwargs) + self.metric_specifications = metric_specifications + + +class Share(ARMBaseModel): # pylint: disable=too-many-instance-attributes + """Represents a share on the Data Box Edge/Gateway device. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: Share on ASE device. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar description: Description for the share. + :vartype description: str + :ivar share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :vartype share_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShareStatus + :ivar monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :vartype monitoring_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringStatus + :ivar azure_container_info: Azure container mapping for the share. + :vartype azure_container_info: ~azure.mgmt.databoxedge.v2021_02_01.models.AzureContainerInfo + :ivar access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :vartype access_protocol: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShareAccessProtocol + :ivar user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :vartype user_access_rights: list[~azure.mgmt.databoxedge.v2021_02_01.models.UserAccessRight] + :ivar client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :vartype client_access_rights: + list[~azure.mgmt.databoxedge.v2021_02_01.models.ClientAccessRight] + :ivar refresh_details: Details of the refresh job on this share. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2021_02_01.models.RefreshDetails + :ivar share_mappings: Share mount point to the role. + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2021_02_01.models.MountPointMap] + :ivar data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DataPolicy + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_status": {"required": True}, + "monitoring_status": {"required": True}, + "access_protocol": {"required": True}, + "share_mappings": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "share_status": {"key": "properties.shareStatus", "type": "str"}, + "monitoring_status": {"key": "properties.monitoringStatus", "type": "str"}, + "azure_container_info": {"key": "properties.azureContainerInfo", "type": "AzureContainerInfo"}, + "access_protocol": {"key": "properties.accessProtocol", "type": "str"}, + "user_access_rights": {"key": "properties.userAccessRights", "type": "[UserAccessRight]"}, + "client_access_rights": {"key": "properties.clientAccessRights", "type": "[ClientAccessRight]"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, + } + + def __init__( + self, + *, + share_status: Union[str, "_models.ShareStatus"], + monitoring_status: Union[str, "_models.MonitoringStatus"], + access_protocol: Union[str, "_models.ShareAccessProtocol"], + description: Optional[str] = None, + azure_container_info: Optional["_models.AzureContainerInfo"] = None, + user_access_rights: Optional[List["_models.UserAccessRight"]] = None, + client_access_rights: Optional[List["_models.ClientAccessRight"]] = None, + refresh_details: Optional["_models.RefreshDetails"] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, + **kwargs + ): + """ + :keyword description: Description for the share. + :paramtype description: str + :keyword share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :paramtype share_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShareStatus + :keyword monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :paramtype monitoring_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringStatus + :keyword azure_container_info: Azure container mapping for the share. + :paramtype azure_container_info: ~azure.mgmt.databoxedge.v2021_02_01.models.AzureContainerInfo + :keyword access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :paramtype access_protocol: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.ShareAccessProtocol + :keyword user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :paramtype user_access_rights: list[~azure.mgmt.databoxedge.v2021_02_01.models.UserAccessRight] + :keyword client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :paramtype client_access_rights: + list[~azure.mgmt.databoxedge.v2021_02_01.models.ClientAccessRight] + :keyword refresh_details: Details of the refresh job on this share. + :paramtype refresh_details: ~azure.mgmt.databoxedge.v2021_02_01.models.RefreshDetails + :keyword data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DataPolicy + """ + super().__init__(**kwargs) + self.system_data = None + self.description = description + self.share_status = share_status + self.monitoring_status = monitoring_status + self.azure_container_info = azure_container_info + self.access_protocol = access_protocol + self.user_access_rights = user_access_rights + self.client_access_rights = client_access_rights + self.refresh_details = refresh_details + self.share_mappings = None + self.data_policy = data_policy + + +class ShareAccessRight(_serialization.Model): + """Specifies the mapping between this particular user and the type of access he has on shares on this device. + + All required parameters must be populated in order to send to Azure. + + :ivar share_id: The share ID. Required. + :vartype share_id: str + :ivar access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShareAccessType + """ + + _validation = { + "share_id": {"required": True}, + "access_type": {"required": True}, + } + + _attribute_map = { + "share_id": {"key": "shareId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, share_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword share_id: The share ID. Required. + :paramtype share_id: str + :keyword access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShareAccessType + """ + super().__init__(**kwargs) + self.share_id = share_id + self.access_type = access_type + + +class ShareList(_serialization.Model): + """Collection of all the shares on the Data Box Edge/Gateway device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of shares. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Share] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Share]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class Sku(_serialization.Model): + """The SKU type. + + :ivar name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", "EP2_256_2T4_W", "EdgeMR_Mini", + "RCA_Small", "RCA_Large", "RDC", and "Management". + :vartype name: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SkuTier + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[Union[str, "_models.SkuName"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, + **kwargs + ): + """ + :keyword name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", "EP2_256_2T4_W", "EdgeMR_Mini", + "RCA_Small", "RCA_Large", "RDC", and "Management". + :paramtype name: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SkuName + :keyword tier: The SKU tier. This is based on the SKU name. "Standard" + :paramtype tier: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SkuTier + """ + super().__init__(**kwargs) + self.name = name + self.tier = tier + + +class SkuCapability(_serialization.Model): + """The metadata to describe the capability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: An invariant to describe the feature. + :vartype name: str + :ivar value: An invariant if the feature is measured by quantity. + :vartype value: str + """ + + _validation = { + "name": {"readonly": True}, + "value": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.value = None + + +class SkuCost(_serialization.Model): + """The metadata for retrieving price info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar meter_id: Used for querying price from commerce. + :vartype meter_id: str + :ivar quantity: The cost quantity. + :vartype quantity: int + :ivar extended_unit: The extended unit. + :vartype extended_unit: str + """ + + _validation = { + "meter_id": {"readonly": True}, + "quantity": {"readonly": True}, + "extended_unit": {"readonly": True}, + } + + _attribute_map = { + "meter_id": {"key": "meterId", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.meter_id = None + self.quantity = None + self.extended_unit = None + + +class SkuInformation(_serialization.Model): + """Sku information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The sku name. + :vartype name: str + :ivar tier: The sku tier. + :vartype tier: str + :ivar kind: The sku kind. + :vartype kind: str + :ivar family: The Sku family. + :vartype family: str + :ivar costs: The pricing info of the Sku. + :vartype costs: list[~azure.mgmt.databoxedge.v2021_02_01.models.SkuCost] + :ivar locations: The locations where Sku is available. + :vartype locations: list[str] + :ivar location_info: The locations where Sku is available with zones and sites info. + :vartype location_info: list[~azure.mgmt.databoxedge.v2021_02_01.models.SkuLocationInfo] + :ivar required_quota_ids: The required quotaIds for the sku to be available. + :vartype required_quota_ids: list[str] + :ivar required_features: The required features for the sku to be available. + :vartype required_features: list[str] + """ + + _validation = { + "name": {"readonly": True}, + "tier": {"readonly": True}, + "kind": {"readonly": True}, + "family": {"readonly": True}, + "costs": {"readonly": True}, + "locations": {"readonly": True}, + "location_info": {"readonly": True}, + "required_quota_ids": {"readonly": True}, + "required_features": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "required_quota_ids": {"key": "requiredQuotaIds", "type": "[str]"}, + "required_features": {"key": "requiredFeatures", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.tier = None + self.kind = None + self.family = None + self.costs = None + self.locations = None + self.location_info = None + self.required_quota_ids = None + self.required_features = None + + +class SkuInformationList(_serialization.Model): + """List of SKU Information objects. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of ResourceTypeSku objects. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.ResourceTypeSku] + :ivar next_link: Links to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ResourceTypeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SkuLocationInfo(_serialization.Model): + """The location info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: The location. + :vartype location: str + :ivar zones: The zones. + :vartype zones: list[str] + :ivar sites: The sites. + :vartype sites: list[str] + """ + + _validation = { + "location": {"readonly": True}, + "zones": {"readonly": True}, + "sites": {"readonly": True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "sites": {"key": "sites", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.location = None + self.zones = None + self.sites = None + + +class StorageAccount(ARMBaseModel): + """Represents a Storage Account on the Data Box Edge/Gateway device. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: StorageAccount object on ASE device. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar description: Description for the storage Account. + :vartype description: str + :ivar storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :vartype storage_account_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountStatus + :ivar data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" and + "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DataPolicy + :ivar storage_account_credential_id: Storage Account Credential Id. + :vartype storage_account_credential_id: str + :ivar blob_endpoint: BlobEndpoint of Storage Account. + :vartype blob_endpoint: str + :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy + set to Cloud. + :vartype container_count: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "data_policy": {"required": True}, + "blob_endpoint": {"readonly": True}, + "container_count": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "storage_account_status": {"key": "properties.storageAccountStatus", "type": "str"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, + "storage_account_credential_id": {"key": "properties.storageAccountCredentialId", "type": "str"}, + "blob_endpoint": {"key": "properties.blobEndpoint", "type": "str"}, + "container_count": {"key": "properties.containerCount", "type": "int"}, + } + + def __init__( + self, + *, + data_policy: Union[str, "_models.DataPolicy"], + description: Optional[str] = None, + storage_account_status: Optional[Union[str, "_models.StorageAccountStatus"]] = None, + storage_account_credential_id: Optional[str] = None, + **kwargs + ): + """ + :keyword description: Description for the storage Account. + :paramtype description: str + :keyword storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :paramtype storage_account_status: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountStatus + :keyword data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" + and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DataPolicy + :keyword storage_account_credential_id: Storage Account Credential Id. + :paramtype storage_account_credential_id: str + """ + super().__init__(**kwargs) + self.system_data = None + self.description = description + self.storage_account_status = storage_account_status + self.data_policy = data_policy + self.storage_account_credential_id = storage_account_credential_id + self.blob_endpoint = None + self.container_count = None + + +class StorageAccountCredential(ARMBaseModel): # pylint: disable=too-many-instance-attributes + """The storage account credential. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: StorageAccountCredential object. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar alias: Alias for the storage account. Required. + :vartype alias: str + :ivar user_name: Username for the storage account. + :vartype user_name: str + :ivar account_key: Encrypted storage key. + :vartype account_key: ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string for the storage account. Use this string if username + and account key are not specified. + :vartype connection_string: str + :ivar ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values are: + "Enabled" and "Disabled". + :vartype ssl_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SSLStatus + :ivar blob_domain_name: Blob end point for private clouds. + :vartype blob_domain_name: str + :ivar account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :vartype account_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AccountType + :ivar storage_account_id: Id of the storage account. + :vartype storage_account_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "alias": {"required": True}, + "ssl_status": {"required": True}, + "account_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "alias": {"key": "properties.alias", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "account_key": {"key": "properties.accountKey", "type": "AsymmetricEncryptedSecret"}, + "connection_string": {"key": "properties.connectionString", "type": "str"}, + "ssl_status": {"key": "properties.sslStatus", "type": "str"}, + "blob_domain_name": {"key": "properties.blobDomainName", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, + } + + def __init__( + self, + *, + alias: str, + ssl_status: Union[str, "_models.SSLStatus"], + account_type: Union[str, "_models.AccountType"], + user_name: Optional[str] = None, + account_key: Optional["_models.AsymmetricEncryptedSecret"] = None, + connection_string: Optional[str] = None, + blob_domain_name: Optional[str] = None, + storage_account_id: Optional[str] = None, + **kwargs + ): + """ + :keyword alias: Alias for the storage account. Required. + :paramtype alias: str + :keyword user_name: Username for the storage account. + :paramtype user_name: str + :keyword account_key: Encrypted storage key. + :paramtype account_key: ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + :keyword connection_string: Connection string for the storage account. Use this string if + username and account key are not specified. + :paramtype connection_string: str + :keyword ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values + are: "Enabled" and "Disabled". + :paramtype ssl_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.SSLStatus + :keyword blob_domain_name: Blob end point for private clouds. + :paramtype blob_domain_name: str + :keyword account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :paramtype account_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AccountType + :keyword storage_account_id: Id of the storage account. + :paramtype storage_account_id: str + """ + super().__init__(**kwargs) + self.system_data = None + self.alias = alias + self.user_name = user_name + self.account_key = account_key + self.connection_string = connection_string + self.ssl_status = ssl_status + self.blob_domain_name = blob_domain_name + self.account_type = account_type + self.storage_account_id = storage_account_id + + +class StorageAccountCredentialList(_serialization.Model): + """The collection of storage account credentials. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The value. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[StorageAccountCredential]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class StorageAccountList(_serialization.Model): + """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of storageAccounts. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SubscriptionRegisteredFeatures(_serialization.Model): + """SubscriptionRegisteredFeatures. + + :ivar name: + :vartype name: str + :ivar state: + :vartype state: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, state: Optional[str] = None, **kwargs): + """ + :keyword name: + :paramtype name: str + :keyword state: + :paramtype state: str + """ + super().__init__(**kwargs) + self.name = name + self.state = state + + +class SymmetricKey(_serialization.Model): + """Symmetric key for authentication. + + :ivar connection_string: Connection string based on the symmetric key. + :vartype connection_string: + ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + """ + + _attribute_map = { + "connection_string": {"key": "connectionString", "type": "AsymmetricEncryptedSecret"}, + } + + def __init__(self, *, connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs): + """ + :keyword connection_string: Connection string based on the symmetric key. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) + self.connection_string = connection_string + + +class SystemData(_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", and "Key". + :vartype created_by_type: str or ~azure.mgmt.databoxedge.v2021_02_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", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.CreatedByType + :ivar last_modified_at: The type of identity that last modified the resource. + :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", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.databoxedge.v2021_02_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", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.CreatedByType + :keyword last_modified_at: The type of identity that last modified the resource. + :paramtype last_modified_at: ~datetime.datetime + """ + super().__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 TrackingInfo(_serialization.Model): + """Tracking courier information. + + :ivar serial_number: Serial number of the device being tracked. + :vartype serial_number: str + :ivar carrier_name: Name of the carrier used in the delivery. + :vartype carrier_name: str + :ivar tracking_id: Tracking ID of the shipment. + :vartype tracking_id: str + :ivar tracking_url: Tracking URL of the shipment. + :vartype tracking_url: str + """ + + _attribute_map = { + "serial_number": {"key": "serialNumber", "type": "str"}, + "carrier_name": {"key": "carrierName", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "tracking_url": {"key": "trackingUrl", "type": "str"}, + } + + def __init__( + self, + *, + serial_number: Optional[str] = None, + carrier_name: Optional[str] = None, + tracking_id: Optional[str] = None, + tracking_url: Optional[str] = None, + **kwargs + ): + """ + :keyword serial_number: Serial number of the device being tracked. + :paramtype serial_number: str + :keyword carrier_name: Name of the carrier used in the delivery. + :paramtype carrier_name: str + :keyword tracking_id: Tracking ID of the shipment. + :paramtype tracking_id: str + :keyword tracking_url: Tracking URL of the shipment. + :paramtype tracking_url: str + """ + super().__init__(**kwargs) + self.serial_number = serial_number + self.carrier_name = carrier_name + self.tracking_id = tracking_id + self.tracking_url = tracking_url + + +class TriggerList(_serialization.Model): + """Collection of all trigger on the data box edge device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of triggers. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.Trigger] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Trigger]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class TriggerSupportPackageRequest(ARMBaseModel): + """The request object for trigger support package. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar minimum_time_stamp: MinimumTimeStamp from where logs need to be collected. + :vartype minimum_time_stamp: ~datetime.datetime + :ivar maximum_time_stamp: MaximumTimeStamp until where logs need to be collected. + :vartype maximum_time_stamp: ~datetime.datetime + :ivar include: Type of files, which need to be included in the logs + This will contain the type of logs (Default/DefaultWithDumps/None/All/DefaultWithArchived) + or a comma separated list of log types that are required. + :vartype include: 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"}, + "minimum_time_stamp": {"key": "properties.minimumTimeStamp", "type": "iso-8601"}, + "maximum_time_stamp": {"key": "properties.maximumTimeStamp", "type": "iso-8601"}, + "include": {"key": "properties.include", "type": "str"}, + } + + def __init__( + self, + *, + minimum_time_stamp: Optional[datetime.datetime] = None, + maximum_time_stamp: Optional[datetime.datetime] = None, + include: Optional[str] = None, + **kwargs + ): + """ + :keyword minimum_time_stamp: MinimumTimeStamp from where logs need to be collected. + :paramtype minimum_time_stamp: ~datetime.datetime + :keyword maximum_time_stamp: MaximumTimeStamp until where logs need to be collected. + :paramtype maximum_time_stamp: ~datetime.datetime + :keyword include: Type of files, which need to be included in the logs + This will contain the type of logs (Default/DefaultWithDumps/None/All/DefaultWithArchived) + or a comma separated list of log types that are required. + :paramtype include: str + """ + super().__init__(**kwargs) + self.minimum_time_stamp = minimum_time_stamp + self.maximum_time_stamp = maximum_time_stamp + self.include = include + + +class UpdateDetails(_serialization.Model): + """Update Specific attributes. + + :ivar update_title: Title of the Update. + :vartype update_title: str + :ivar update_size: Size of the update(In Bytes). + :vartype update_size: float + :ivar update_type: Type of the Update. Known values are: "Software", "Kubernetes", and + "Firmware". + :vartype update_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateType + :ivar target_version: Target Version number. + :vartype target_version: str + :ivar friendly_version_number: Friendly Version Number. + :vartype friendly_version_number: str + :ivar estimated_install_time_in_mins: Estimated Install Time for the update. + :vartype estimated_install_time_in_mins: int + :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". + :vartype reboot_behavior: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.InstallRebootBehavior + :ivar installation_impact: Impact of Installing an updateType. Known values are: "None", + "DeviceRebooted", and "KubernetesWorkloadsDown". + :vartype installation_impact: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.InstallationImpact + :ivar status: Status of the update. Known values are: "DownloadPending", "DownloadStarted", + "DownloadCompleted", "InstallStarted", and "InstallCompleted". + :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateStatus + """ + + _attribute_map = { + "update_title": {"key": "updateTitle", "type": "str"}, + "update_size": {"key": "updateSize", "type": "float"}, + "update_type": {"key": "updateType", "type": "str"}, + "target_version": {"key": "targetVersion", "type": "str"}, + "friendly_version_number": {"key": "friendlyVersionNumber", "type": "str"}, + "estimated_install_time_in_mins": {"key": "estimatedInstallTimeInMins", "type": "int"}, + "reboot_behavior": {"key": "rebootBehavior", "type": "str"}, + "installation_impact": {"key": "installationImpact", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + update_title: Optional[str] = None, + update_size: Optional[float] = None, + update_type: Optional[Union[str, "_models.UpdateType"]] = None, + target_version: Optional[str] = None, + friendly_version_number: Optional[str] = None, + estimated_install_time_in_mins: Optional[int] = None, + reboot_behavior: Optional[Union[str, "_models.InstallRebootBehavior"]] = None, + installation_impact: Optional[Union[str, "_models.InstallationImpact"]] = None, + status: Optional[Union[str, "_models.UpdateStatus"]] = None, + **kwargs + ): + """ + :keyword update_title: Title of the Update. + :paramtype update_title: str + :keyword update_size: Size of the update(In Bytes). + :paramtype update_size: float + :keyword update_type: Type of the Update. Known values are: "Software", "Kubernetes", and + "Firmware". + :paramtype update_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateType + :keyword target_version: Target Version number. + :paramtype target_version: str + :keyword friendly_version_number: Friendly Version Number. + :paramtype friendly_version_number: str + :keyword estimated_install_time_in_mins: Estimated Install Time for the update. + :paramtype estimated_install_time_in_mins: int + :keyword reboot_behavior: Indicates if updates are available and at least one of the updates + needs a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". + :paramtype reboot_behavior: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.InstallRebootBehavior + :keyword installation_impact: Impact of Installing an updateType. Known values are: "None", + "DeviceRebooted", and "KubernetesWorkloadsDown". + :paramtype installation_impact: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.InstallationImpact + :keyword status: Status of the update. Known values are: "DownloadPending", "DownloadStarted", + "DownloadCompleted", "InstallStarted", and "InstallCompleted". + :paramtype status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateStatus + """ + super().__init__(**kwargs) + self.update_title = update_title + self.update_size = update_size + self.update_type = update_type + self.target_version = target_version + self.friendly_version_number = friendly_version_number + self.estimated_install_time_in_mins = estimated_install_time_in_mins + self.reboot_behavior = reboot_behavior + self.installation_impact = installation_impact + self.status = status + + +class UpdateDownloadProgress(_serialization.Model): + """Details about the download progress of update. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar download_phase: The download phase. Known values are: "Unknown", "Initializing", + "Downloading", and "Verifying". + :vartype download_phase: str or ~azure.mgmt.databoxedge.v2021_02_01.models.DownloadPhase + :ivar percent_complete: Percentage of completion. + :vartype percent_complete: int + :ivar total_bytes_to_download: Total bytes to download. + :vartype total_bytes_to_download: float + :ivar total_bytes_downloaded: Total bytes downloaded. + :vartype total_bytes_downloaded: float + :ivar number_of_updates_to_download: Number of updates to download. + :vartype number_of_updates_to_download: int + :ivar number_of_updates_downloaded: Number of updates downloaded. + :vartype number_of_updates_downloaded: int + """ + + _validation = { + "download_phase": {"readonly": True}, + "percent_complete": {"readonly": True}, + "total_bytes_to_download": {"readonly": True}, + "total_bytes_downloaded": {"readonly": True}, + "number_of_updates_to_download": {"readonly": True}, + "number_of_updates_downloaded": {"readonly": True}, + } + + _attribute_map = { + "download_phase": {"key": "downloadPhase", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "total_bytes_to_download": {"key": "totalBytesToDownload", "type": "float"}, + "total_bytes_downloaded": {"key": "totalBytesDownloaded", "type": "float"}, + "number_of_updates_to_download": {"key": "numberOfUpdatesToDownload", "type": "int"}, + "number_of_updates_downloaded": {"key": "numberOfUpdatesDownloaded", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.download_phase = None + self.percent_complete = None + self.total_bytes_to_download = None + self.total_bytes_downloaded = None + self.number_of_updates_to_download = None + self.number_of_updates_downloaded = None + + +class UpdateInstallProgress(_serialization.Model): + """Progress details during installation of updates. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar percent_complete: Percentage completed. + :vartype percent_complete: int + :ivar number_of_updates_to_install: Number of updates to install. + :vartype number_of_updates_to_install: int + :ivar number_of_updates_installed: Number of updates installed. + :vartype number_of_updates_installed: int + """ + + _validation = { + "percent_complete": {"readonly": True}, + "number_of_updates_to_install": {"readonly": True}, + "number_of_updates_installed": {"readonly": True}, + } + + _attribute_map = { + "percent_complete": {"key": "percentComplete", "type": "int"}, + "number_of_updates_to_install": {"key": "numberOfUpdatesToInstall", "type": "int"}, + "number_of_updates_installed": {"key": "numberOfUpdatesInstalled", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.percent_complete = None + self.number_of_updates_to_install = None + self.number_of_updates_installed = None + + +class UpdateSummary(ARMBaseModel): # pylint: disable=too-many-instance-attributes + """Details about ongoing updates and availability of updates on the device. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: UpdateSummary Result. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar device_version_number: The current version of the device in format: 1.2.17312.13.",. + :vartype device_version_number: str + :ivar friendly_device_version_name: The current version of the device in text format. + :vartype friendly_device_version_name: str + :ivar device_last_scanned_date_time: The last time when a scan was done on the device. + :vartype device_last_scanned_date_time: ~datetime.datetime + :ivar last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :vartype last_completed_scan_job_date_time: ~datetime.datetime + :ivar last_successful_scan_job_time: Time when the last scan job is successfully completed. + :vartype last_successful_scan_job_time: ~datetime.datetime + :ivar last_completed_download_job_date_time: The time when the last Download job was completed + (success/cancelled/failed) on the appliance. + :vartype last_completed_download_job_date_time: ~datetime.datetime + :ivar last_completed_download_job_id: JobId of the last ran download job.(Can be + success/cancelled/failed). + :vartype last_completed_download_job_id: str + :ivar last_download_job_status: JobStatus of the last ran download job. Known values are: + "Invalid", "Running", "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". + :vartype last_download_job_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.JobStatus + :ivar last_successful_install_job_date_time: The time when the Last Install job was completed + successfully on the appliance. + :vartype last_successful_install_job_date_time: ~datetime.datetime + :ivar last_completed_install_job_date_time: The time when the last Install job was completed + (success/cancelled/failed) on the appliance. + :vartype last_completed_install_job_date_time: ~datetime.datetime + :ivar last_completed_install_job_id: JobId of the last ran install job.(Can be + success/cancelled/failed). + :vartype last_completed_install_job_id: str + :ivar last_install_job_status: JobStatus of the last ran install job. Known values are: + "Invalid", "Running", "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". + :vartype last_install_job_status: str or ~azure.mgmt.databoxedge.v2021_02_01.models.JobStatus + :ivar total_number_of_updates_available: The number of updates available for the current device + version as per the last device scan. + :vartype total_number_of_updates_available: int + :ivar total_number_of_updates_pending_download: The total number of items pending download. + :vartype total_number_of_updates_pending_download: int + :ivar total_number_of_updates_pending_install: The total number of items pending install. + :vartype total_number_of_updates_pending_install: int + :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". + :vartype reboot_behavior: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.InstallRebootBehavior + :ivar ongoing_update_operation: The current update operation. Known values are: "None", "Scan", + "Download", and "Install". + :vartype ongoing_update_operation: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateOperation + :ivar in_progress_download_job_id: The job ID of the download job in progress. + :vartype in_progress_download_job_id: str + :ivar in_progress_install_job_id: The job ID of the install job in progress. + :vartype in_progress_install_job_id: str + :ivar in_progress_download_job_started_date_time: The time when the currently running download + (if any) started. + :vartype in_progress_download_job_started_date_time: ~datetime.datetime + :ivar in_progress_install_job_started_date_time: The time when the currently running install + (if any) started. + :vartype in_progress_install_job_started_date_time: ~datetime.datetime + :ivar update_titles: The list of updates available for install. + :vartype update_titles: list[str] + :ivar updates: The list of updates available for install. + :vartype updates: list[~azure.mgmt.databoxedge.v2021_02_01.models.UpdateDetails] + :ivar total_update_size_in_bytes: The total size of updates available for download in bytes. + :vartype total_update_size_in_bytes: float + :ivar total_time_in_minutes: The total time in Minutes. + :vartype total_time_in_minutes: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_completed_download_job_date_time": {"readonly": True}, + "last_completed_download_job_id": {"readonly": True}, + "last_download_job_status": {"readonly": True}, + "last_completed_install_job_date_time": {"readonly": True}, + "last_completed_install_job_id": {"readonly": True}, + "last_install_job_status": {"readonly": True}, + "total_number_of_updates_available": {"readonly": True}, + "total_number_of_updates_pending_download": {"readonly": True}, + "total_number_of_updates_pending_install": {"readonly": True}, + "reboot_behavior": {"readonly": True}, + "ongoing_update_operation": {"readonly": True}, + "in_progress_download_job_id": {"readonly": True}, + "in_progress_install_job_id": {"readonly": True}, + "in_progress_download_job_started_date_time": {"readonly": True}, + "in_progress_install_job_started_date_time": {"readonly": True}, + "update_titles": {"readonly": True}, + "updates": {"readonly": True}, + "total_update_size_in_bytes": {"readonly": True}, + "total_time_in_minutes": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "device_version_number": {"key": "properties.deviceVersionNumber", "type": "str"}, + "friendly_device_version_name": {"key": "properties.friendlyDeviceVersionName", "type": "str"}, + "device_last_scanned_date_time": {"key": "properties.deviceLastScannedDateTime", "type": "iso-8601"}, + "last_completed_scan_job_date_time": {"key": "properties.lastCompletedScanJobDateTime", "type": "iso-8601"}, + "last_successful_scan_job_time": {"key": "properties.lastSuccessfulScanJobTime", "type": "iso-8601"}, + "last_completed_download_job_date_time": { + "key": "properties.lastCompletedDownloadJobDateTime", + "type": "iso-8601", + }, + "last_completed_download_job_id": {"key": "properties.lastCompletedDownloadJobId", "type": "str"}, + "last_download_job_status": {"key": "properties.lastDownloadJobStatus", "type": "str"}, + "last_successful_install_job_date_time": { + "key": "properties.lastSuccessfulInstallJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_date_time": { + "key": "properties.lastCompletedInstallJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_id": {"key": "properties.lastCompletedInstallJobId", "type": "str"}, + "last_install_job_status": {"key": "properties.lastInstallJobStatus", "type": "str"}, + "total_number_of_updates_available": {"key": "properties.totalNumberOfUpdatesAvailable", "type": "int"}, + "total_number_of_updates_pending_download": { + "key": "properties.totalNumberOfUpdatesPendingDownload", + "type": "int", + }, + "total_number_of_updates_pending_install": { + "key": "properties.totalNumberOfUpdatesPendingInstall", + "type": "int", + }, + "reboot_behavior": {"key": "properties.rebootBehavior", "type": "str"}, + "ongoing_update_operation": {"key": "properties.ongoingUpdateOperation", "type": "str"}, + "in_progress_download_job_id": {"key": "properties.inProgressDownloadJobId", "type": "str"}, + "in_progress_install_job_id": {"key": "properties.inProgressInstallJobId", "type": "str"}, + "in_progress_download_job_started_date_time": { + "key": "properties.inProgressDownloadJobStartedDateTime", + "type": "iso-8601", + }, + "in_progress_install_job_started_date_time": { + "key": "properties.inProgressInstallJobStartedDateTime", + "type": "iso-8601", + }, + "update_titles": {"key": "properties.updateTitles", "type": "[str]"}, + "updates": {"key": "properties.updates", "type": "[UpdateDetails]"}, + "total_update_size_in_bytes": {"key": "properties.totalUpdateSizeInBytes", "type": "float"}, + "total_time_in_minutes": {"key": "properties.totalTimeInMinutes", "type": "int"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + device_version_number: Optional[str] = None, + friendly_device_version_name: Optional[str] = None, + device_last_scanned_date_time: Optional[datetime.datetime] = None, + last_completed_scan_job_date_time: Optional[datetime.datetime] = None, + last_successful_scan_job_time: Optional[datetime.datetime] = None, + last_successful_install_job_date_time: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword device_version_number: The current version of the device in format: 1.2.17312.13.",. + :paramtype device_version_number: str + :keyword friendly_device_version_name: The current version of the device in text format. + :paramtype friendly_device_version_name: str + :keyword device_last_scanned_date_time: The last time when a scan was done on the device. + :paramtype device_last_scanned_date_time: ~datetime.datetime + :keyword last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :paramtype last_completed_scan_job_date_time: ~datetime.datetime + :keyword last_successful_scan_job_time: Time when the last scan job is successfully completed. + :paramtype last_successful_scan_job_time: ~datetime.datetime + :keyword last_successful_install_job_date_time: The time when the Last Install job was + completed successfully on the appliance. + :paramtype last_successful_install_job_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.system_data = None + self.device_version_number = device_version_number + self.friendly_device_version_name = friendly_device_version_name + self.device_last_scanned_date_time = device_last_scanned_date_time + self.last_completed_scan_job_date_time = last_completed_scan_job_date_time + self.last_successful_scan_job_time = last_successful_scan_job_time + self.last_completed_download_job_date_time = None + self.last_completed_download_job_id = None + self.last_download_job_status = None + self.last_successful_install_job_date_time = last_successful_install_job_date_time + self.last_completed_install_job_date_time = None + self.last_completed_install_job_id = None + self.last_install_job_status = None + self.total_number_of_updates_available = None + self.total_number_of_updates_pending_download = None + self.total_number_of_updates_pending_install = None + self.reboot_behavior = None + self.ongoing_update_operation = None + self.in_progress_download_job_id = None + self.in_progress_install_job_id = None + self.in_progress_download_job_started_date_time = None + self.in_progress_install_job_started_date_time = None + self.update_titles = None + self.updates = None + self.total_update_size_in_bytes = None + self.total_time_in_minutes = None + + +class UploadCertificateRequest(_serialization.Model): + """The upload certificate request. + + All required parameters must be populated in order to send to Azure. + + :ivar authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :vartype authentication_type: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.AuthenticationType + :ivar certificate: The base64 encoded certificate raw data. Required. + :vartype certificate: str + """ + + _validation = { + "certificate": {"required": True}, + } + + _attribute_map = { + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "certificate": {"key": "properties.certificate", "type": "str"}, + } + + def __init__( + self, + *, + certificate: str, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + **kwargs + ): + """ + :keyword authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype authentication_type: str or + ~azure.mgmt.databoxedge.v2021_02_01.models.AuthenticationType + :keyword certificate: The base64 encoded certificate raw data. Required. + :paramtype certificate: str + """ + super().__init__(**kwargs) + self.authentication_type = authentication_type + self.certificate = certificate + + +class UploadCertificateResponse(_serialization.Model): + """The upload registration certificate response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :vartype auth_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AuthenticationType + :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. + :vartype resource_id: str + :ivar aad_authority: Azure Active Directory tenant authority. + :vartype aad_authority: str + :ivar aad_tenant_id: Azure Active Directory tenant ID. + :vartype aad_tenant_id: str + :ivar service_principal_client_id: Azure Active Directory service principal client ID. + :vartype service_principal_client_id: str + :ivar service_principal_object_id: Azure Active Directory service principal object ID. + :vartype service_principal_object_id: str + :ivar azure_management_endpoint_audience: The azure management endpoint audience. + :vartype azure_management_endpoint_audience: str + :ivar aad_audience: Identifier of the target resource that is the recipient of the requested + token. + :vartype aad_audience: str + """ + + _validation = { + "resource_id": {"readonly": True}, + "aad_authority": {"readonly": True}, + "aad_tenant_id": {"readonly": True}, + "service_principal_client_id": {"readonly": True}, + "service_principal_object_id": {"readonly": True}, + "azure_management_endpoint_audience": {"readonly": True}, + "aad_audience": {"readonly": True}, + } + + _attribute_map = { + "auth_type": {"key": "authType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "aad_authority": {"key": "aadAuthority", "type": "str"}, + "aad_tenant_id": {"key": "aadTenantId", "type": "str"}, + "service_principal_client_id": {"key": "servicePrincipalClientId", "type": "str"}, + "service_principal_object_id": {"key": "servicePrincipalObjectId", "type": "str"}, + "azure_management_endpoint_audience": {"key": "azureManagementEndpointAudience", "type": "str"}, + "aad_audience": {"key": "aadAudience", "type": "str"}, + } + + def __init__(self, *, auth_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs): + """ + :keyword auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype auth_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.AuthenticationType + """ + super().__init__(**kwargs) + self.auth_type = auth_type + self.resource_id = None + self.aad_authority = None + self.aad_tenant_id = None + self.service_principal_client_id = None + self.service_principal_object_id = None + self.azure_management_endpoint_audience = None + self.aad_audience = None + + +class User(ARMBaseModel): + """Represents a user who has access to one or more shares on the Data Box Edge/Gateway device. + + 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: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar system_data: User in DataBoxEdge Resource. + :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01.models.SystemData + :ivar encrypted_password: The password details. + :vartype encrypted_password: + ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + :ivar share_access_rights: List of shares that the user has rights on. This field should not be + specified during user creation. + :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2021_02_01.models.ShareAccessRight] + :ivar user_type: Type of the user. Required. Known values are: "Share", "LocalManagement", and + "ARM". + :vartype user_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.UserType + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_access_rights": {"readonly": True}, + "user_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "encrypted_password": {"key": "properties.encryptedPassword", "type": "AsymmetricEncryptedSecret"}, + "share_access_rights": {"key": "properties.shareAccessRights", "type": "[ShareAccessRight]"}, + "user_type": {"key": "properties.userType", "type": "str"}, + } + + def __init__( + self, + *, + user_type: Union[str, "_models.UserType"], + encrypted_password: Optional["_models.AsymmetricEncryptedSecret"] = None, + **kwargs + ): + """ + :keyword encrypted_password: The password details. + :paramtype encrypted_password: + ~azure.mgmt.databoxedge.v2021_02_01.models.AsymmetricEncryptedSecret + :keyword user_type: Type of the user. Required. Known values are: "Share", "LocalManagement", + and "ARM". + :paramtype user_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.UserType + """ + super().__init__(**kwargs) + self.system_data = None + self.encrypted_password = encrypted_password + self.share_access_rights = None + self.user_type = user_type + + +class UserAccessRight(_serialization.Model): + """The mapping between a particular user and the access type on the SMB share. + + All required parameters must be populated in order to send to Azure. + + :ivar user_id: User ID (already existing in the device). Required. + :vartype user_id: str + :ivar access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShareAccessType + """ + + _validation = { + "user_id": {"required": True}, + "access_type": {"required": True}, + } + + _attribute_map = { + "user_id": {"key": "userId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, user_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword user_id: User ID (already existing in the device). Required. + :paramtype user_id: str + :keyword access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :paramtype access_type: str or ~azure.mgmt.databoxedge.v2021_02_01.models.ShareAccessType + """ + super().__init__(**kwargs) + self.user_id = user_id + self.access_type = access_type + + +class UserList(_serialization.Model): + """Collection of users. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of users. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01.models.User] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[User]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/__init__.py new file mode 100644 index 000000000000..29c0c74f0582 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/__init__.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 ._operations import Operations +from ._available_skus_operations import AvailableSkusOperations +from ._devices_operations import DevicesOperations +from ._alerts_operations import AlertsOperations +from ._bandwidth_schedules_operations import BandwidthSchedulesOperations +from ._diagnostic_settings_operations import DiagnosticSettingsOperations +from ._jobs_operations import JobsOperations +from ._nodes_operations import NodesOperations +from ._operations_status_operations import OperationsStatusOperations +from ._orders_operations import OrdersOperations +from ._roles_operations import RolesOperations +from ._addons_operations import AddonsOperations +from ._monitoring_config_operations import MonitoringConfigOperations +from ._shares_operations import SharesOperations +from ._storage_account_credentials_operations import StorageAccountCredentialsOperations +from ._storage_accounts_operations import StorageAccountsOperations +from ._containers_operations import ContainersOperations +from ._triggers_operations import TriggersOperations +from ._support_packages_operations import SupportPackagesOperations +from ._users_operations import UsersOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "DiagnosticSettingsOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "SupportPackagesOperations", + "UsersOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_addons_operations.py new file mode 100644 index 000000000000..54358652a2ba --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_addons_operations.py @@ -0,0 +1,715 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_role_request( + device_name: str, role_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, addon_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`addons` 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 list_by_role( + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Addon"]: + """Lists all the addons configured in the role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :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 Addon or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AddonList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + + @distributed_trace + def get( + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: + """Gets a specific addon by name. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Addon or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Addon + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Addon", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + def _create_or_update_initial( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Addon", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: ~azure.mgmt.databoxedge.v2021_02_01.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2021_02_01.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + addon=addon, + 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("Addon", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @distributed_trace + def begin_delete( + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the addon on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_alerts_operations.py new file mode 100644 index 000000000000..5c2632ea46f6 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_alerts_operations.py @@ -0,0 +1,278 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`alerts` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Alert"]: + """Gets all the alerts for a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: + """Gets an alert by name. + + Gets an alert by name. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The alert name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Alert + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Alert", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_available_skus_operations.py new file mode 100644 index 000000000000..a677f6082635 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_available_skus_operations.py @@ -0,0 +1,166 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`available_skus` 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 list(self, **kwargs: Any) -> Iterable["_models.DataBoxEdgeSku"]: + """List all the available Skus and information related to them. + + List all the available Skus and information related to them. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_bandwidth_schedules_operations.py new file mode 100644 index 000000000000..bf6d15908b82 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_bandwidth_schedules_operations.py @@ -0,0 +1,693 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.BandwidthSchedule"]: + """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.BandwidthSchedule: + """Gets the properties of the specified bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BandwidthSchedule or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _create_or_update_initial( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_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("BandwidthSchedule", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the specified bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_containers_operations.py new file mode 100644 index 000000000000..a1c28b1496cf --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_containers_operations.py @@ -0,0 +1,899 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_storage_account_request( + device_name: str, storage_account_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`containers` 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 list_by_storage_account( + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Container"]: + """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. + + Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The storage Account name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :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 Container or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ContainerList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + + @distributed_trace + def get( + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: + """Gets a container by name. + + Gets a container by name. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container Name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Container or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Container + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Container", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _create_or_update_initial( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Container", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: ~azure.mgmt.databoxedge.v2021_02_01.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2021_02_01.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + container=container, + 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("Container", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @distributed_trace + def begin_delete( + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the container on the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + + @distributed_trace + def begin_refresh( + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Refreshes the container metadata with the data from the cloud. + + Refreshes the container metadata with the data from the cloud. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._refresh_initial( # type: ignore + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_devices_operations.py new file mode 100644 index 000000000000..77c2d321a507 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_devices_operations.py @@ -0,0 +1,2263 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", + ) # 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"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_download_updates_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_generate_certificate_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_extended_information_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_install_updates_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_settings_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_scan_for_updates_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_security_settings_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_update_extended_information_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_get_update_summary_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_upload_certificate_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`devices` 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 list_by_subscription( + self, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: + """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. + + :param expand: Specify $expand=details to populate additional fields related to the resource or + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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, + expand=expand, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: + """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. + + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param expand: Specify $expand=details to populate additional fields related to the resource or + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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, + expand=expand, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: + """Gets the properties of the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload + def create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevicePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace + def begin_download_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Downloads the updates on a Data Box Edge/Data Box Gateway device. + + Downloads the updates on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._download_updates_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace + def generate_certificate( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: + """Generates certificate for activation key. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenerateCertResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.GenerateCertResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace + def get_extended_information( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + + @distributed_trace + def begin_install_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Installs the updates on the Data Box Edge/Data Box Gateway device. + + Installs the updates on the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._install_updates_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + + @distributed_trace + def get_network_settings( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: + """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkSettings or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.NetworkSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkSettings", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + + @distributed_trace + def begin_scan_for_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Scans for updates on a Data Box Edge/Data Box Gateway device. + + Scans for updates on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._scan_for_updates_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + + def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2021_02_01.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2021_02_01.models.SecuritySettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_security_settings_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_name, + security_settings=security_settings, + 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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfoPatch + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace + def get_update_summary(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. + + Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UpdateSummary or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.UpdateSummary + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateSummary", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_diagnostic_settings_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_diagnostic_settings_operations.py new file mode 100644 index 000000000000..ffbf998e0398 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_diagnostic_settings_operations.py @@ -0,0 +1,737 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_diagnostic_proactive_log_collection_settings_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticProactiveLogCollectionSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_diagnostic_proactive_log_collection_settings_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticProactiveLogCollectionSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_get_diagnostic_remote_support_settings_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticRemoteSupportSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_diagnostic_remote_support_settings_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticRemoteSupportSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`diagnostic_settings` 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_diagnostic_proactive_log_collection_settings( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DiagnosticProactiveLogCollectionSettings: + """Gets the proactive log collection settings of the specified Data Box Edge/Data Box Gateway + device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticProactiveLogCollectionSettings or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticProactiveLogCollectionSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DiagnosticProactiveLogCollectionSettings] = kwargs.pop("cls", None) + + request = build_get_diagnostic_proactive_log_collection_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_diagnostic_proactive_log_collection_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticProactiveLogCollectionSettings", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_diagnostic_proactive_log_collection_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticProactiveLogCollectionSettings/default" + } + + def _update_diagnostic_proactive_log_collection_settings_initial( # pylint: disable=inconsistent-return-statements + self, + device_name: str, + resource_group_name: str, + proactive_log_collection_settings: Union[_models.DiagnosticProactiveLogCollectionSettings, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(proactive_log_collection_settings, (IO, bytes)): + _content = proactive_log_collection_settings + else: + _json = self._serialize.body(proactive_log_collection_settings, "DiagnosticProactiveLogCollectionSettings") + + request = build_update_diagnostic_proactive_log_collection_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_diagnostic_proactive_log_collection_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _update_diagnostic_proactive_log_collection_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticProactiveLogCollectionSettings/default" + } + + @overload + def begin_update_diagnostic_proactive_log_collection_settings( + self, + device_name: str, + resource_group_name: str, + proactive_log_collection_settings: _models.DiagnosticProactiveLogCollectionSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the proactive log collection settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param proactive_log_collection_settings: The proactive log collection settings. Required. + :type proactive_log_collection_settings: + ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticProactiveLogCollectionSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @overload + def begin_update_diagnostic_proactive_log_collection_settings( + self, + device_name: str, + resource_group_name: str, + proactive_log_collection_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the proactive log collection settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param proactive_log_collection_settings: The proactive log collection settings. Required. + :type proactive_log_collection_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_update_diagnostic_proactive_log_collection_settings( + self, + device_name: str, + resource_group_name: str, + proactive_log_collection_settings: Union[_models.DiagnosticProactiveLogCollectionSettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the proactive log collection settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param proactive_log_collection_settings: The proactive log collection settings. Is either a + model type or a IO type. Required. + :type proactive_log_collection_settings: + ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticProactiveLogCollectionSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_diagnostic_proactive_log_collection_settings_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_name, + proactive_log_collection_settings=proactive_log_collection_settings, + 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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_update_diagnostic_proactive_log_collection_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticProactiveLogCollectionSettings/default" + } + + @distributed_trace + def get_diagnostic_remote_support_settings( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DiagnosticRemoteSupportSettings: + """Gets the diagnostic remote support settings of the specified Data Box Edge/Data Box Gateway + device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticRemoteSupportSettings or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticRemoteSupportSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DiagnosticRemoteSupportSettings] = kwargs.pop("cls", None) + + request = build_get_diagnostic_remote_support_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_diagnostic_remote_support_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticRemoteSupportSettings", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_diagnostic_remote_support_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticRemoteSupportSettings/default" + } + + def _update_diagnostic_remote_support_settings_initial( # pylint: disable=inconsistent-return-statements + self, + device_name: str, + resource_group_name: str, + diagnostic_remote_support_settings: Union[_models.DiagnosticRemoteSupportSettings, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(diagnostic_remote_support_settings, (IO, bytes)): + _content = diagnostic_remote_support_settings + else: + _json = self._serialize.body(diagnostic_remote_support_settings, "DiagnosticRemoteSupportSettings") + + request = build_update_diagnostic_remote_support_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_diagnostic_remote_support_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _update_diagnostic_remote_support_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticRemoteSupportSettings/default" + } + + @overload + def begin_update_diagnostic_remote_support_settings( + self, + device_name: str, + resource_group_name: str, + diagnostic_remote_support_settings: _models.DiagnosticRemoteSupportSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the diagnostic remote support settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param diagnostic_remote_support_settings: The diagnostic remote support settings. Required. + :type diagnostic_remote_support_settings: + ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticRemoteSupportSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @overload + def begin_update_diagnostic_remote_support_settings( + self, + device_name: str, + resource_group_name: str, + diagnostic_remote_support_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the diagnostic remote support settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param diagnostic_remote_support_settings: The diagnostic remote support settings. Required. + :type diagnostic_remote_support_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_update_diagnostic_remote_support_settings( + self, + device_name: str, + resource_group_name: str, + diagnostic_remote_support_settings: Union[_models.DiagnosticRemoteSupportSettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the diagnostic remote support settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param diagnostic_remote_support_settings: The diagnostic remote support settings. Is either a + model type or a IO type. Required. + :type diagnostic_remote_support_settings: + ~azure.mgmt.databoxedge.v2021_02_01.models.DiagnosticRemoteSupportSettings or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_diagnostic_remote_support_settings_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_name, + diagnostic_remote_support_settings=diagnostic_remote_support_settings, + 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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_update_diagnostic_remote_support_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/diagnosticRemoteSupportSettings/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_jobs_operations.py new file mode 100644 index 000000000000..36c9cec4638a --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_jobs_operations.py @@ -0,0 +1,156 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`jobs` 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: + """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. + + Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The job name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Job or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Job", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_monitoring_config_operations.py new file mode 100644 index 000000000000..4bb7728c30cd --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_monitoring_config_operations.py @@ -0,0 +1,716 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + device_name: str, role_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` 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 list( + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.MonitoringMetricConfiguration"]: + """Lists metric configurations in a role. + + Lists metric configurations in a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :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 MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + + @distributed_trace + def get( + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: + """Gets a metric configuration of a role. + + Gets a metric configuration of a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MonitoringMetricConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + def _create_or_update_initial( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + monitoring_metric_configuration=monitoring_metric_configuration, + 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("MonitoringMetricConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @distributed_trace + def begin_delete( + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """deletes a new metric configuration for a role. + + deletes a new metric configuration for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_nodes_operations.py new file mode 100644 index 000000000000..5b551118a558 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_nodes_operations.py @@ -0,0 +1,181 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`nodes` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Node"]: + """Gets all the nodes currently configured under this Data Box Edge device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Node or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NodeList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_operations.py new file mode 100644 index 000000000000..18fb54d4bef5 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_operations.py @@ -0,0 +1,160 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataBoxEdge/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 Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`operations` 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """List all the supported operations. + + List all the supported operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_operations_status_operations.py new file mode 100644 index 000000000000..6c7ae4241586 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_operations_status_operations.py @@ -0,0 +1,156 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`operations_status` 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: + """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. + + Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The job name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Job or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Job + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Job", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_orders_operations.py new file mode 100644 index 000000000000..c074311de74a --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_orders_operations.py @@ -0,0 +1,759 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request(device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_dc_access_code_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`orders` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Order"]: + """Lists all the orders related to a Data Box Edge/Data Box Gateway device. + + Lists all the orders related to a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Order or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OrderList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: + """Gets a specific order by name. + + Gets a specific order by name. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Order or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Order + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Order", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _create_or_update_initial( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Order", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: ~azure.mgmt.databoxedge.v2021_02_01.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2021_02_01.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + resource_group_name=resource_group_name, + order=order, + 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("Order", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the order related to the device. + + Deletes the order related to the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace + def list_dc_access_code(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DCAccessCode: + """Gets the DCAccess Code. + + Gets the DCAccess Code. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DCAccessCode or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.DCAccessCode + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DCAccessCode", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_roles_operations.py new file mode 100644 index 000000000000..ff930ce3a506 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_roles_operations.py @@ -0,0 +1,675 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`roles` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Role"]: + """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Role or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: + """Gets a specific role by name. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Role or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Role + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Role", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _create_or_update_initial( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Role", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: ~azure.mgmt.databoxedge.v2021_02_01.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2021_02_01.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + role=role, + 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("Role", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the role on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_shares_operations.py new file mode 100644 index 000000000000..2d534bddaeae --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_shares_operations.py @@ -0,0 +1,832 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`shares` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Share"]: + """Lists all the shares in a Data Box Edge/Data Box Gateway device. + + Lists all the shares in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 Share or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ShareList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: + """Gets a share by name. + + Gets a share by name. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Share or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Share + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Share", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _create_or_update_initial( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Share", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: ~azure.mgmt.databoxedge.v2021_02_01.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2021_02_01.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + share=share, + 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("Share", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the share on the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + + @distributed_trace + def begin_refresh(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Refreshes the share metadata with the data from the cloud. + + Refreshes the share metadata with the data from the cloud. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._refresh_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_storage_account_credentials_operations.py new file mode 100644 index 000000000000..582947dfe93c --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_storage_account_credentials_operations.py @@ -0,0 +1,700 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccountCredential"]: + """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. + + Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace + def get( + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: + """Gets the properties of the specified storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountCredential or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _create_or_update_initial( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + storage_account_credential=storage_account_credential, + 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("StorageAccountCredential", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_storage_accounts_operations.py new file mode 100644 index 000000000000..f974d4216696 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_storage_accounts_operations.py @@ -0,0 +1,706 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, storage_account_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, storage_account_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, storage_account_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccount"]: + """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. + + Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :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 StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + + @distributed_trace + def get( + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: + """Gets a StorageAccount by name. + + Gets a StorageAccount by name. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The storage account name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + def _create_or_update_initial( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + storage_account=storage_account, + 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("StorageAccount", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @distributed_trace + def begin_delete( + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_support_packages_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_support_packages_operations.py new file mode 100644 index 000000000000..d91273c5a016 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_support_packages_operations.py @@ -0,0 +1,311 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_trigger_support_package_request( + device_name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggerSupportPackage", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class SupportPackagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`support_packages` 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") + + def _trigger_support_package_initial( # pylint: disable=inconsistent-return-statements + self, + device_name: str, + resource_group_name: str, + trigger_support_package_request: Union[_models.TriggerSupportPackageRequest, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger_support_package_request, (IO, bytes)): + _content = trigger_support_package_request + else: + _json = self._serialize.body(trigger_support_package_request, "TriggerSupportPackageRequest") + + request = build_trigger_support_package_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._trigger_support_package_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _trigger_support_package_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggerSupportPackage" + } + + @overload + def begin_trigger_support_package( + self, + device_name: str, + resource_group_name: str, + trigger_support_package_request: _models.TriggerSupportPackageRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Triggers support package on the device. + + Triggers support package on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger_support_package_request: The trigger support package request object. Required. + :type trigger_support_package_request: + ~azure.mgmt.databoxedge.v2021_02_01.models.TriggerSupportPackageRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @overload + def begin_trigger_support_package( + self, + device_name: str, + resource_group_name: str, + trigger_support_package_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Triggers support package on the device. + + Triggers support package on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger_support_package_request: The trigger support package request object. Required. + :type trigger_support_package_request: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_trigger_support_package( + self, + device_name: str, + resource_group_name: str, + trigger_support_package_request: Union[_models.TriggerSupportPackageRequest, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Triggers support package on the device. + + Triggers support package on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger_support_package_request: The trigger support package request object. Is either a + model type or a IO type. Required. + :type trigger_support_package_request: + ~azure.mgmt.databoxedge.v2021_02_01.models.TriggerSupportPackageRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._trigger_support_package_initial( # type: ignore + device_name=device_name, + resource_group_name=resource_group_name, + trigger_support_package_request=trigger_support_package_request, + 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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_trigger_support_package.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggerSupportPackage" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_triggers_operations.py new file mode 100644 index 000000000000..da0bf07b03d2 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_triggers_operations.py @@ -0,0 +1,681 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`triggers` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Trigger"]: + """Lists all the triggers configured in the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context + tag property. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TriggerList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: + """Get a specific trigger by name. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Trigger or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.Trigger + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Trigger", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _create_or_update_initial( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("Trigger", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: ~azure.mgmt.databoxedge.v2021_02_01.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2021_02_01.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + trigger=trigger, + 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("Trigger", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the trigger on the gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_users_operations.py new file mode 100644 index 000000000000..dcc3f2cbaaa2 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/operations/_users_operations.py @@ -0,0 +1,684 @@ +# 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. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01.DataBoxEdgeManagementClient`'s + :attr:`users` 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 list_by_data_box_edge_device( + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.User"]: + """Gets all the users registered on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param filter: Specify $filter='Type eq :code:``' to filter on user type property. + Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either User or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UserList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: + """Gets the properties of the specified user. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: User or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01.models.User + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("User", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _create_or_update_initial( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("User", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: ~azure.mgmt.databoxedge.v2021_02_01.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2021_02_01.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + user=user, + 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("User", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the user on a databox edge/gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: Literal["2021-02-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + device_name=device_name, + name=name, + resource_group_name=resource_group_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/py.typed b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/__init__.py index e63196b6b98f..d2bcf6a47896 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/__init__.py @@ -7,10 +7,20 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] +from ._version import VERSION + +__version__ = VERSION try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_configuration.py index 0e27cd60be90..ae5723d90006 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_configuration.py @@ -6,65 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import sys +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :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, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-02-01-preview"] = kwargs.pop("api_version", "2021-02-01-preview") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-02-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_data_box_edge_management_client.py index 16f27eeeaf02..6cb13ed0b3e8 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_data_box_edge_management_client.py @@ -6,59 +6,63 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import AddonsOperations -from .operations import MonitoringConfigOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from . import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.databoxedge.v2021_02_01_preview.operations.Operations :ivar available_skus: AvailableSkusOperations operations - :vartype available_skus: azure.mgmt.databoxedge.v2021_02_01_preview.operations.AvailableSkusOperations + :vartype available_skus: + azure.mgmt.databoxedge.v2021_02_01_preview.operations.AvailableSkusOperations :ivar devices: DevicesOperations operations :vartype devices: azure.mgmt.databoxedge.v2021_02_01_preview.operations.DevicesOperations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2021_02_01_preview.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2021_02_01_preview.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2021_02_01_preview.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2021_02_01_preview.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2021_02_01_preview.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2021_02_01_preview.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2021_02_01_preview.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2021_02_01_preview.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -66,109 +70,108 @@ class DataBoxEdgeManagementClient(object): :ivar addons: AddonsOperations operations :vartype addons: azure.mgmt.databoxedge.v2021_02_01_preview.operations.AddonsOperations :ivar monitoring_config: MonitoringConfigOperations operations - :vartype monitoring_config: azure.mgmt.databoxedge.v2021_02_01_preview.operations.MonitoringConfigOperations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2021_02_01_preview.operations.MonitoringConfigOperations :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2021_02_01_preview.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2021_02_01_preview.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2021_02_01_preview.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2021_02_01_preview.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2021_02_01_preview.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations :vartype containers: azure.mgmt.databoxedge.v2021_02_01_preview.operations.ContainersOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2021_02_01_preview.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2021_02_01_preview.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) self.monitoring_config = MonitoringConfigOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None + + 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) -> None: self._client.close() - def __enter__(self): - # type: () -> DataBoxEdgeManagementClient + def __enter__(self) -> "DataBoxEdgeManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_metadata.json b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_metadata.json index c4a292c62cd0..ec6448e66482 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_metadata.json +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_metadata.json @@ -5,25 +5,25 @@ "name": "DataBoxEdgeManagementClient", "filename": "_data_box_edge_management_client", "description": "The DataBoxEdge Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"DataBoxEdgeManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription ID.", + "signature": "subscription_id: str,", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The subscription ID.", + "description": "The subscription ID. Required.", "docstring_type": "str", "required": true } @@ -48,19 +48,19 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "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=None, # type: Optional[str]", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -117,4 +116,4 @@ "triggers": "TriggersOperations", "users": "UsersOperations" } -} \ No newline at end of file +} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_vendor.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_version.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/__init__.py index c33d46ee91d8..fcb8775eaa10 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/__init__.py @@ -7,4 +7,17 @@ # -------------------------------------------------------------------------- from ._data_box_edge_management_client import DataBoxEdgeManagementClient -__all__ = ['DataBoxEdgeManagementClient'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DataBoxEdgeManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_configuration.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_configuration.py index f2b772a27070..a0d19aa0883d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_configuration.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_configuration.py @@ -6,61 +6,67 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" -class DataBoxEdgeManagementClientConfiguration(Configuration): +class DataBoxEdgeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DataBoxEdgeManagementClient. 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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2021-02-01-preview"] = kwargs.pop("api_version", "2021-02-01-preview") + 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(DataBoxEdgeManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-02-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-databoxedge/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-databoxedge/{}".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') + 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 = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_data_box_edge_management_client.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_data_box_edge_management_client.py index 7967f62c7ed8..95c00ce44809 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_data_box_edge_management_client.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_data_box_edge_management_client.py @@ -6,57 +6,63 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import DataBoxEdgeManagementClientConfiguration +from .operations import ( + AddonsOperations, + AlertsOperations, + AvailableSkusOperations, + BandwidthSchedulesOperations, + ContainersOperations, + DevicesOperations, + JobsOperations, + MonitoringConfigOperations, + NodesOperations, + Operations, + OperationsStatusOperations, + OrdersOperations, + RolesOperations, + SharesOperations, + StorageAccountCredentialsOperations, + StorageAccountsOperations, + TriggersOperations, + UsersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import DataBoxEdgeManagementClientConfiguration -from .operations import Operations -from .operations import AvailableSkusOperations -from .operations import DevicesOperations -from .operations import AlertsOperations -from .operations import BandwidthSchedulesOperations -from .operations import JobsOperations -from .operations import NodesOperations -from .operations import OperationsStatusOperations -from .operations import OrdersOperations -from .operations import RolesOperations -from .operations import AddonsOperations -from .operations import MonitoringConfigOperations -from .operations import SharesOperations -from .operations import StorageAccountCredentialsOperations -from .operations import StorageAccountsOperations -from .operations import ContainersOperations -from .operations import TriggersOperations -from .operations import UsersOperations -from .. import models - - -class DataBoxEdgeManagementClient(object): + +class DataBoxEdgeManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The DataBoxEdge Client. :ivar operations: Operations operations :vartype operations: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.Operations :ivar available_skus: AvailableSkusOperations operations - :vartype available_skus: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.AvailableSkusOperations + :vartype available_skus: + azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.AvailableSkusOperations :ivar devices: DevicesOperations operations :vartype devices: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.DevicesOperations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.AlertsOperations :ivar bandwidth_schedules: BandwidthSchedulesOperations operations - :vartype bandwidth_schedules: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.BandwidthSchedulesOperations + :vartype bandwidth_schedules: + azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.BandwidthSchedulesOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.JobsOperations :ivar nodes: NodesOperations operations :vartype nodes: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.NodesOperations :ivar operations_status: OperationsStatusOperations operations - :vartype operations_status: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.OperationsStatusOperations + :vartype operations_status: + azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.OperationsStatusOperations :ivar orders: OrdersOperations operations :vartype orders: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.OrdersOperations :ivar roles: RolesOperations operations @@ -64,97 +70,102 @@ class DataBoxEdgeManagementClient(object): :ivar addons: AddonsOperations operations :vartype addons: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.AddonsOperations :ivar monitoring_config: MonitoringConfigOperations operations - :vartype monitoring_config: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.MonitoringConfigOperations + :vartype monitoring_config: + azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.MonitoringConfigOperations :ivar shares: SharesOperations operations :vartype shares: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.SharesOperations :ivar storage_account_credentials: StorageAccountCredentialsOperations operations - :vartype storage_account_credentials: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.StorageAccountCredentialsOperations + :vartype storage_account_credentials: + azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.StorageAccountCredentialsOperations :ivar storage_accounts: StorageAccountsOperations operations - :vartype storage_accounts: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.StorageAccountsOperations + :vartype storage_accounts: + azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.StorageAccountsOperations :ivar containers: ContainersOperations operations - :vartype containers: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.ContainersOperations + :vartype containers: + azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.ContainersOperations :ivar triggers: TriggersOperations operations :vartype triggers: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.TriggersOperations :ivar users: UsersOperations operations :vartype users: azure.mgmt.databoxedge.v2021_02_01_preview.aio.operations.UsersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription ID. + :param subscription_id: The subscription ID. Required. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = DataBoxEdgeManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = DataBoxEdgeManagementClientConfiguration( + 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)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.available_skus = AvailableSkusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.devices = DevicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.available_skus = AvailableSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.devices = DevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) self.bandwidth_schedules = BandwidthSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.nodes = NodesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.nodes = NodesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations_status = OperationsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.orders = OrdersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.roles = RolesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.orders = OrdersOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(self._client, self._config, self._serialize, self._deserialize) self.monitoring_config = MonitoringConfigOperations( - self._client, self._config, self._serialize, self._deserialize) - self.shares = SharesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.shares = SharesOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_account_credentials = StorageAccountCredentialsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.storage_accounts = StorageAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.containers = ContainersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.triggers = TriggersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.users = UsersOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + self._client, self._config, self._serialize, self._deserialize + ) + self.containers = ContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/__init__.py index d70057be6458..febac852eb27 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/__init__.py @@ -25,23 +25,29 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'AddonsOperations', - 'MonitoringConfigOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_addons_operations.py index 86afe57c3d9a..fa1b2586358d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_addons_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,109 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._addons_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_role_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AddonsOperations: - """AddonsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`addons` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_role( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AddonList"]: + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Addon"]: """Lists all the addons configured in the role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AddonList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_role.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -116,76 +154,81 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_role.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + @distributed_trace_async async def get( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Addon": + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: """Gets a specific addon by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } async def _create_or_update_initial( self, @@ -193,43 +236,55 @@ async def _create_or_update_initial( role_name: str, addon_name: str, resource_group_name: str, - addon: "_models.Addon", - **kwargs - ) -> Optional["_models.Addon"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Addon"]] + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(addon, 'Addon') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -238,52 +293,148 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload async def begin_create_or_update( self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, - addon: "_models.Addon", - **kwargs - ) -> AsyncLROPoller["_models.Addon"]: + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: """Create or update a addon. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param addon: The addon properties. + :param addon: The addon properties. Required. :type addon: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Addon or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Addon or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -291,79 +442,77 @@ async def begin_create_or_update( addon_name=addon_name, resource_group_name=resource_group_name, addon=addon, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -373,78 +522,81 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - role_name: str, - addon_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the addon on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, addon_name=addon_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_alerts_operations.py index bf5ecb55d5f5..04536e1463e2 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._alerts_operations import build_get_request, build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AlertsOperations: - """AlertsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.AlertList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,71 +144,75 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Alert": + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_available_skus_operations.py index 020b0d430244..f221b29de99e 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,129 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._available_skus_operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AvailableSkusOperations: - """AvailableSkusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeSkuList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +137,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_bandwidth_schedules_operations.py index d03f2c936a6c..8d85559a550f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._bandwidth_schedules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BandwidthSchedulesOperations: - """BandwidthSchedulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.BandwidthSchedulesList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +151,132 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.BandwidthSchedule": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> Optional["_models.BandwidthSchedule"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +285,219 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - parameters: "_models.BandwidthSchedule", - **kwargs - ) -> AsyncLROPoller["_models.BandwidthSchedule"]: + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +507,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_containers_operations.py index db42d8f6017f..1609f25ffa4f 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,149 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._containers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_storage_account_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainersOperations: - """ContainersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_storage_account( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ContainerList"]: + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,78 +157,83 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Container": + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } async def _create_or_update_initial( self, @@ -197,43 +241,55 @@ async def _create_or_update_initial( storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> Optional["_models.Container"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -242,54 +298,157 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, - container: "_models.Container", - **kwargs - ) -> AsyncLROPoller["_models.Container"]: + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Container or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Container or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, @@ -297,79 +456,77 @@ async def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -379,119 +536,120 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -501,80 +659,81 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - storage_account_name: str, - container_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_devices_operations.py index f7ed6510a9d8..afbf89f3b05a 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,154 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._devices_operations import ( + build_create_or_update_request, + build_create_or_update_security_settings_request, + build_delete_request, + build_download_updates_request, + build_generate_certificate_request, + build_get_extended_information_request, + build_get_network_settings_request, + build_get_request, + build_get_update_summary_request, + build_install_updates_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_scan_for_updates_request, + build_update_extended_information_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations: - """DevicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_subscription( - self, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,74 +162,92 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.DataBoxEdgeDeviceList"]: + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,226 +256,335 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDevice": + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } async def _create_or_update_initial( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> "_models.DataBoxEdgeDevice": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - data_box_edge_device: "_models.DataBoxEdgeDevice", - **kwargs - ) -> AsyncLROPoller["_models.DataBoxEdgeDevice"]: + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. - :type data_box_edge_device: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -415,171 +594,250 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload async def update( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDevicePatch", - **kwargs - ) -> "_models.DataBoxEdgeDevice": + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevicePatch or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - async def _download_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + async def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -589,223 +847,242 @@ async def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def begin_download_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._download_updates_initial( + raw_result = await self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + @distributed_trace_async async def generate_certificate( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.GenerateCertResponse": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: """Generates certificate for activation key. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenerateCertResponse, or the result of cls(response) + :return: GenerateCertResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.GenerateCertResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCertResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.generate_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateCertResponse', pipeline_response) + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate'} # type: ignore + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace_async async def get_extended_information( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - async def _install_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + async def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -815,165 +1092,178 @@ async def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def begin_install_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._install_updates_initial( + raw_result = await self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace_async async def get_network_settings( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.NetworkSettings": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - async def _scan_for_updates_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + async def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -983,113 +1273,130 @@ async def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + @distributed_trace_async async def begin_scan_for_updates( - self, - device_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._scan_for_updates_initial( + raw_result = await self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - async def _create_or_update_security_settings_initial( + async def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1099,265 +1406,504 @@ async def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload async def begin_create_or_update_security_settings( self, device_name: str, resource_group_name: str, - security_settings: "_models.SecuritySettings", - **kwargs + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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: + """ + + @distributed_trace_async + async def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SecuritySettings or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_security_settings_initial( + raw_result = await self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload async def update_extended_information( self, device_name: str, resource_group_name: str, - parameters: "_models.DataBoxEdgeDeviceExtendedInfoPatch", - **kwargs - ) -> "_models.DataBoxEdgeDeviceExtendedInfo": + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The patch object. - :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch + :param parameters: The patch object. Required. + :type parameters: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDeviceExtendedInfoPatch') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation'} # type: ignore + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace_async async def get_update_summary( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.UpdateSummary": - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload async def upload_certificate( self, device_name: str, resource_group_name: str, - parameters: "_models.UploadCertificateRequest", - **kwargs - ) -> "_models.UploadCertificateResponse": + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_jobs_operations.py index 5ceed56b4b62..75bd42289f8a 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class JobsOperations: - """JobsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_monitoring_config_operations.py index dfc0baf622f3..2f3f5f684032 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_monitoring_config_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_monitoring_config_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,149 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._monitoring_config_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MonitoringConfigOperations: - """MonitoringConfigOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.MonitoringMetricConfigurationList"]: + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MonitoringMetricConfiguration"]: """Lists metric configurations in a role. Lists metric configurations in a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 MonitoringMetricConfigurationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfigurationList', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,116 +157,134 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + + @distributed_trace_async async def get( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.MonitoringMetricConfiguration": + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: """Gets a metric configuration of a role. Gets a metric configuration of a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringMetricConfiguration, or the result of cls(response) + :return: MonitoringMetricConfiguration or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } async def _create_or_update_initial( self, device_name: str, role_name: str, resource_group_name: str, - monitoring_metric_configuration: "_models.MonitoringMetricConfiguration", - **kwargs - ) -> Optional["_models.MonitoringMetricConfiguration"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MonitoringMetricConfiguration"]] + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(monitoring_metric_configuration, 'MonitoringMetricConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -236,127 +293,227 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async async def begin_create_or_update( self, device_name: str, role_name: str, resource_group_name: str, - monitoring_metric_configuration: "_models.MonitoringMetricConfiguration", - **kwargs - ) -> AsyncLROPoller["_models.MonitoringMetricConfiguration"]: + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MonitoringMetricConfiguration]: """Creates a new metric configuration or updates an existing one for a role. Creates a new metric configuration or updates an existing one for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param monitoring_metric_configuration: The metric configuration. - :type monitoring_metric_configuration: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 MonitoringMetricConfiguration or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, monitoring_metric_configuration=monitoring_metric_configuration, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) - + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -366,75 +523,78 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - role_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """deletes a new metric configuration for a role. deletes a new metric configuration for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_nodes_operations.py index 58223a6302d1..f1d5956d1982 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,135 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._nodes_operations import build_list_by_data_box_edge_device_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NodesOperations: - """NodesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.NodeList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +143,8 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_operations.py index 16b0a070e9e5..21277a643788 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,128 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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") - def list( - self, - **kwargs - ) -> AsyncIterable["_models.OperationsList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +136,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_operations_status_operations.py index 56aa4ff163fc..742f6a710b6b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._operations_status_operations import build_get_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsStatusOperations: - """OperationsStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Job": + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_orders_operations.py index 6a0ff451ec52..1ca653e0310c 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._orders_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_list_dc_access_code_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OrdersOperations: - """OrdersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.OrderList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,110 +154,123 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Order": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace_async + async def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } async def _create_or_update_initial( - self, - device_name: str, - resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> Optional["_models.Order"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -226,120 +279,207 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload async def begin_create_or_update( self, device_name: str, resource_group_name: str, - order: "_models.Order", - **kwargs - ) -> AsyncLROPoller["_models.Order"]: + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Order or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Order or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -349,130 +489,139 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - async def begin_delete( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace_async async def list_dc_access_code( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.DCAccessCode": + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DCAccessCode: """Gets the DCAccess Code. Gets the DCAccess Code. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DCAccessCode, or the result of cls(response) + :return: DCAccessCode or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DCAccessCode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DCAccessCode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_dc_access_code.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DCAccessCode', pipeline_response) + deserialized = self._deserialize("DCAccessCode", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_dc_access_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode'} # type: ignore + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_roles_operations.py index 48018de5770a..0a5de91818a9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,105 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._roles_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RolesOperations: - """RolesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.RoleList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,114 +151,125 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Role": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> Optional["_models.Role"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -228,125 +278,210 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - role: "_models.Role", - **kwargs - ) -> AsyncLROPoller["_models.Role"]: + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Role or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Role or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -356,73 +491,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_shares_operations.py index f8b3bcb3f44a..4929d799af26 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._shares_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, + build_refresh_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SharesOperations: - """SharesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.ShareList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +154,127 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Share": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> Optional["_models.Share"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +283,216 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - share: "_models.Share", - **kwargs - ) -> AsyncLROPoller["_models.Share"]: + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Share or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Share or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,112 +502,116 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + async def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -477,75 +621,78 @@ async def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } + @distributed_trace_async async def begin_refresh( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_storage_account_credentials_operations.py index 23af9ec14777..dc981c507164 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,146 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_account_credentials_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountCredentialsOperations: - """StorageAccountCredentialsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountCredentialList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,114 +154,132 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace_async async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccountCredential": + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> Optional["_models.StorageAccountCredential"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -230,125 +288,221 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - storage_account_credential: "_models.StorageAccountCredential", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccountCredential"]: + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccountCredential or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,73 +512,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_storage_accounts_operations.py index f3e0964591b0..1beb7a212693 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._storage_accounts_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountsOperations: - """StorageAccountsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - **kwargs - ) -> AsyncIterable["_models.StorageAccountList"]: + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,116 +153,134 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + @distributed_trace_async async def get( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs - ) -> "_models.StorageAccount": + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } async def _create_or_update_initial( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -232,127 +289,225 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload async def begin_create_or_update( self, device_name: str, storage_account_name: str, resource_group_name: str, - storage_account: "_models.StorageAccount", - **kwargs - ) -> AsyncLROPoller["_models.StorageAccount"]: + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -362,73 +517,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - storage_account_name: str, - resource_group_name: str, - **kwargs + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_triggers_operations.py index 6f3140528c6f..4faf84f2d0e1 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,147 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._triggers_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TriggersOperations: - """TriggersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.TriggerList"]: + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +155,125 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.Trigger": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> Optional["_models.Trigger"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,125 +282,213 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - trigger: "_models.Trigger", - **kwargs - ) -> AsyncLROPoller["_models.Trigger"]: + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.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 Trigger or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Trigger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 Trigger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -362,73 +498,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_users_operations.py index ae5d2249538f..cd6d24a86604 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/aio/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,148 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_data_box_edge_device_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UsersOperations: - """UsersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.aio.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 def list_by_data_box_edge_device( - self, - device_name: str, - resource_group_name: str, - expand: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.UserList"]: + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,114 +156,125 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs - ) -> "_models.User": + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace_async + async def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } async def _create_or_update_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - user: "_models.User", - **kwargs - ) -> Optional["_models.User"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -234,126 +283,213 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, - user: "_models.User", - **kwargs - ) -> AsyncLROPoller["_models.User"]: + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either User or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + async def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.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 User or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_initial( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -363,73 +499,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + @distributed_trace_async async def begin_delete( - self, - device_name: str, - name: str, - resource_group_name: str, - **kwargs + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/__init__.py index 427bbdbc0d20..5be8b0c836df 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/__init__.py @@ -6,483 +6,368 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ARMBaseModel - from ._models_py3 import Addon - from ._models_py3 import AddonList - from ._models_py3 import Address - from ._models_py3 import Alert - from ._models_py3 import AlertErrorDetails - from ._models_py3 import AlertList - from ._models_py3 import ArcAddon - from ._models_py3 import AsymmetricEncryptedSecret - from ._models_py3 import Authentication - from ._models_py3 import AzureContainerInfo - from ._models_py3 import BandwidthSchedule - from ._models_py3 import BandwidthSchedulesList - from ._models_py3 import ClientAccessRight - from ._models_py3 import CloudEdgeManagementRole - from ._models_py3 import CloudErrorBody - from ._models_py3 import CniConfig - from ._models_py3 import ComputeResource - from ._models_py3 import ContactDetails - from ._models_py3 import Container - from ._models_py3 import ContainerList - from ._models_py3 import DCAccessCode - from ._models_py3 import DataBoxEdgeDevice - from ._models_py3 import DataBoxEdgeDeviceExtendedInfo - from ._models_py3 import DataBoxEdgeDeviceExtendedInfoPatch - from ._models_py3 import DataBoxEdgeDeviceList - from ._models_py3 import DataBoxEdgeDevicePatch - from ._models_py3 import DataBoxEdgeMoveRequest - from ._models_py3 import DataBoxEdgeSku - from ._models_py3 import DataBoxEdgeSkuList - from ._models_py3 import EdgeProfile - from ._models_py3 import EdgeProfilePatch - from ._models_py3 import EdgeProfileSubscription - from ._models_py3 import EdgeProfileSubscriptionPatch - from ._models_py3 import EtcdInfo - from ._models_py3 import FileEventTrigger - from ._models_py3 import FileSourceInfo - from ._models_py3 import GenerateCertResponse - from ._models_py3 import ImageRepositoryCredential - from ._models_py3 import IoTAddon - from ._models_py3 import IoTDeviceInfo - from ._models_py3 import IoTEdgeAgentInfo - from ._models_py3 import IoTRole - from ._models_py3 import Ipv4Config - from ._models_py3 import Ipv6Config - from ._models_py3 import Job - from ._models_py3 import JobErrorDetails - from ._models_py3 import JobErrorItem - from ._models_py3 import KubernetesClusterInfo - from ._models_py3 import KubernetesIPConfiguration - from ._models_py3 import KubernetesRole - from ._models_py3 import KubernetesRoleCompute - from ._models_py3 import KubernetesRoleNetwork - from ._models_py3 import KubernetesRoleResources - from ._models_py3 import KubernetesRoleStorage - from ._models_py3 import KubernetesRoleStorageClassInfo - from ._models_py3 import LoadBalancerConfig - from ._models_py3 import MECRole - from ._models_py3 import MetricConfiguration - from ._models_py3 import MetricCounter - from ._models_py3 import MetricCounterSet - from ._models_py3 import MetricDimension - from ._models_py3 import MetricDimensionV1 - from ._models_py3 import MetricSpecificationV1 - from ._models_py3 import MonitoringMetricConfiguration - from ._models_py3 import MonitoringMetricConfigurationList - from ._models_py3 import MountPointMap - from ._models_py3 import NetworkAdapter - from ._models_py3 import NetworkAdapterPosition - from ._models_py3 import NetworkSettings - from ._models_py3 import Node - from ._models_py3 import NodeInfo - from ._models_py3 import NodeList - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import Order - from ._models_py3 import OrderList - from ._models_py3 import OrderStatus - from ._models_py3 import PeriodicTimerEventTrigger - from ._models_py3 import PeriodicTimerSourceInfo - from ._models_py3 import RefreshDetails - from ._models_py3 import ResourceIdentity - from ._models_py3 import ResourceMoveDetails - from ._models_py3 import ResourceTypeSku - from ._models_py3 import Role - from ._models_py3 import RoleList - from ._models_py3 import RoleSinkInfo - from ._models_py3 import Secret - from ._models_py3 import SecuritySettings - from ._models_py3 import ServiceSpecification - from ._models_py3 import Share - from ._models_py3 import ShareAccessRight - from ._models_py3 import ShareList - from ._models_py3 import Sku - from ._models_py3 import SkuCost - from ._models_py3 import SkuInformation - from ._models_py3 import SkuInformationList - from ._models_py3 import SkuLocationInfo - from ._models_py3 import StorageAccount - from ._models_py3 import StorageAccountCredential - from ._models_py3 import StorageAccountCredentialList - from ._models_py3 import StorageAccountList - from ._models_py3 import SubscriptionRegisteredFeatures - from ._models_py3 import SymmetricKey - from ._models_py3 import SystemData - from ._models_py3 import TrackingInfo - from ._models_py3 import Trigger - from ._models_py3 import TriggerList - from ._models_py3 import UpdateDetails - from ._models_py3 import UpdateDownloadProgress - from ._models_py3 import UpdateInstallProgress - from ._models_py3 import UpdateSummary - from ._models_py3 import UploadCertificateRequest - from ._models_py3 import UploadCertificateResponse - from ._models_py3 import User - from ._models_py3 import UserAccessRight - from ._models_py3 import UserList -except (SyntaxError, ImportError): - from ._models import ARMBaseModel # type: ignore - from ._models import Addon # type: ignore - from ._models import AddonList # type: ignore - from ._models import Address # type: ignore - from ._models import Alert # type: ignore - from ._models import AlertErrorDetails # type: ignore - from ._models import AlertList # type: ignore - from ._models import ArcAddon # type: ignore - from ._models import AsymmetricEncryptedSecret # type: ignore - from ._models import Authentication # type: ignore - from ._models import AzureContainerInfo # type: ignore - from ._models import BandwidthSchedule # type: ignore - from ._models import BandwidthSchedulesList # type: ignore - from ._models import ClientAccessRight # type: ignore - from ._models import CloudEdgeManagementRole # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import CniConfig # type: ignore - from ._models import ComputeResource # type: ignore - from ._models import ContactDetails # type: ignore - from ._models import Container # type: ignore - from ._models import ContainerList # type: ignore - from ._models import DCAccessCode # type: ignore - from ._models import DataBoxEdgeDevice # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfo # type: ignore - from ._models import DataBoxEdgeDeviceExtendedInfoPatch # type: ignore - from ._models import DataBoxEdgeDeviceList # type: ignore - from ._models import DataBoxEdgeDevicePatch # type: ignore - from ._models import DataBoxEdgeMoveRequest # type: ignore - from ._models import DataBoxEdgeSku # type: ignore - from ._models import DataBoxEdgeSkuList # type: ignore - from ._models import EdgeProfile # type: ignore - from ._models import EdgeProfilePatch # type: ignore - from ._models import EdgeProfileSubscription # type: ignore - from ._models import EdgeProfileSubscriptionPatch # type: ignore - from ._models import EtcdInfo # type: ignore - from ._models import FileEventTrigger # type: ignore - from ._models import FileSourceInfo # type: ignore - from ._models import GenerateCertResponse # type: ignore - from ._models import ImageRepositoryCredential # type: ignore - from ._models import IoTAddon # type: ignore - from ._models import IoTDeviceInfo # type: ignore - from ._models import IoTEdgeAgentInfo # type: ignore - from ._models import IoTRole # type: ignore - from ._models import Ipv4Config # type: ignore - from ._models import Ipv6Config # type: ignore - from ._models import Job # type: ignore - from ._models import JobErrorDetails # type: ignore - from ._models import JobErrorItem # type: ignore - from ._models import KubernetesClusterInfo # type: ignore - from ._models import KubernetesIPConfiguration # type: ignore - from ._models import KubernetesRole # type: ignore - from ._models import KubernetesRoleCompute # type: ignore - from ._models import KubernetesRoleNetwork # type: ignore - from ._models import KubernetesRoleResources # type: ignore - from ._models import KubernetesRoleStorage # type: ignore - from ._models import KubernetesRoleStorageClassInfo # type: ignore - from ._models import LoadBalancerConfig # type: ignore - from ._models import MECRole # type: ignore - from ._models import MetricConfiguration # type: ignore - from ._models import MetricCounter # type: ignore - from ._models import MetricCounterSet # type: ignore - from ._models import MetricDimension # type: ignore - from ._models import MetricDimensionV1 # type: ignore - from ._models import MetricSpecificationV1 # type: ignore - from ._models import MonitoringMetricConfiguration # type: ignore - from ._models import MonitoringMetricConfigurationList # type: ignore - from ._models import MountPointMap # type: ignore - from ._models import NetworkAdapter # type: ignore - from ._models import NetworkAdapterPosition # type: ignore - from ._models import NetworkSettings # type: ignore - from ._models import Node # type: ignore - from ._models import NodeInfo # type: ignore - from ._models import NodeList # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import Order # type: ignore - from ._models import OrderList # type: ignore - from ._models import OrderStatus # type: ignore - from ._models import PeriodicTimerEventTrigger # type: ignore - from ._models import PeriodicTimerSourceInfo # type: ignore - from ._models import RefreshDetails # type: ignore - from ._models import ResourceIdentity # type: ignore - from ._models import ResourceMoveDetails # type: ignore - from ._models import ResourceTypeSku # type: ignore - from ._models import Role # type: ignore - from ._models import RoleList # type: ignore - from ._models import RoleSinkInfo # type: ignore - from ._models import Secret # type: ignore - from ._models import SecuritySettings # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Share # type: ignore - from ._models import ShareAccessRight # type: ignore - from ._models import ShareList # type: ignore - from ._models import Sku # type: ignore - from ._models import SkuCost # type: ignore - from ._models import SkuInformation # type: ignore - from ._models import SkuInformationList # type: ignore - from ._models import SkuLocationInfo # type: ignore - from ._models import StorageAccount # type: ignore - from ._models import StorageAccountCredential # type: ignore - from ._models import StorageAccountCredentialList # type: ignore - from ._models import StorageAccountList # type: ignore - from ._models import SubscriptionRegisteredFeatures # type: ignore - from ._models import SymmetricKey # type: ignore - from ._models import SystemData # type: ignore - from ._models import TrackingInfo # type: ignore - from ._models import Trigger # type: ignore - from ._models import TriggerList # type: ignore - from ._models import UpdateDetails # type: ignore - from ._models import UpdateDownloadProgress # type: ignore - from ._models import UpdateInstallProgress # type: ignore - from ._models import UpdateSummary # type: ignore - from ._models import UploadCertificateRequest # type: ignore - from ._models import UploadCertificateResponse # type: ignore - from ._models import User # type: ignore - from ._models import UserAccessRight # type: ignore - from ._models import UserList # type: ignore +from ._models_py3 import ARMBaseModel +from ._models_py3 import Addon +from ._models_py3 import AddonList +from ._models_py3 import Address +from ._models_py3 import Alert +from ._models_py3 import AlertErrorDetails +from ._models_py3 import AlertList +from ._models_py3 import ArcAddon +from ._models_py3 import AsymmetricEncryptedSecret +from ._models_py3 import Authentication +from ._models_py3 import AzureContainerInfo +from ._models_py3 import BandwidthSchedule +from ._models_py3 import BandwidthSchedulesList +from ._models_py3 import ClientAccessRight +from ._models_py3 import CloudEdgeManagementRole +from ._models_py3 import CloudErrorBody +from ._models_py3 import CniConfig +from ._models_py3 import ComputeResource +from ._models_py3 import ContactDetails +from ._models_py3 import Container +from ._models_py3 import ContainerList +from ._models_py3 import DCAccessCode +from ._models_py3 import DataBoxEdgeDevice +from ._models_py3 import DataBoxEdgeDeviceExtendedInfo +from ._models_py3 import DataBoxEdgeDeviceExtendedInfoPatch +from ._models_py3 import DataBoxEdgeDeviceList +from ._models_py3 import DataBoxEdgeDevicePatch +from ._models_py3 import DataBoxEdgeMoveRequest +from ._models_py3 import DataBoxEdgeSku +from ._models_py3 import DataBoxEdgeSkuList +from ._models_py3 import EdgeProfile +from ._models_py3 import EdgeProfilePatch +from ._models_py3 import EdgeProfileSubscription +from ._models_py3 import EdgeProfileSubscriptionPatch +from ._models_py3 import EtcdInfo +from ._models_py3 import FileEventTrigger +from ._models_py3 import FileSourceInfo +from ._models_py3 import GenerateCertResponse +from ._models_py3 import ImageRepositoryCredential +from ._models_py3 import IoTAddon +from ._models_py3 import IoTDeviceInfo +from ._models_py3 import IoTEdgeAgentInfo +from ._models_py3 import IoTRole +from ._models_py3 import Ipv4Config +from ._models_py3 import Ipv6Config +from ._models_py3 import Job +from ._models_py3 import JobErrorDetails +from ._models_py3 import JobErrorItem +from ._models_py3 import KubernetesClusterInfo +from ._models_py3 import KubernetesIPConfiguration +from ._models_py3 import KubernetesRole +from ._models_py3 import KubernetesRoleCompute +from ._models_py3 import KubernetesRoleNetwork +from ._models_py3 import KubernetesRoleResources +from ._models_py3 import KubernetesRoleStorage +from ._models_py3 import KubernetesRoleStorageClassInfo +from ._models_py3 import LoadBalancerConfig +from ._models_py3 import MECRole +from ._models_py3 import MetricConfiguration +from ._models_py3 import MetricCounter +from ._models_py3 import MetricCounterSet +from ._models_py3 import MetricDimension +from ._models_py3 import MetricDimensionV1 +from ._models_py3 import MetricSpecificationV1 +from ._models_py3 import MonitoringMetricConfiguration +from ._models_py3 import MonitoringMetricConfigurationList +from ._models_py3 import MountPointMap +from ._models_py3 import NetworkAdapter +from ._models_py3 import NetworkAdapterPosition +from ._models_py3 import NetworkSettings +from ._models_py3 import Node +from ._models_py3 import NodeInfo +from ._models_py3 import NodeList +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import Order +from ._models_py3 import OrderList +from ._models_py3 import OrderStatus +from ._models_py3 import PeriodicTimerEventTrigger +from ._models_py3 import PeriodicTimerSourceInfo +from ._models_py3 import RefreshDetails +from ._models_py3 import ResourceIdentity +from ._models_py3 import ResourceMoveDetails +from ._models_py3 import ResourceTypeSku +from ._models_py3 import Role +from ._models_py3 import RoleList +from ._models_py3 import RoleSinkInfo +from ._models_py3 import Secret +from ._models_py3 import SecuritySettings +from ._models_py3 import ServiceSpecification +from ._models_py3 import Share +from ._models_py3 import ShareAccessRight +from ._models_py3 import ShareList +from ._models_py3 import Sku +from ._models_py3 import SkuCapability +from ._models_py3 import SkuCost +from ._models_py3 import SkuInformation +from ._models_py3 import SkuInformationList +from ._models_py3 import SkuLocationInfo +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCredential +from ._models_py3 import StorageAccountCredentialList +from ._models_py3 import StorageAccountList +from ._models_py3 import SubscriptionRegisteredFeatures +from ._models_py3 import SymmetricKey +from ._models_py3 import SystemData +from ._models_py3 import TrackingInfo +from ._models_py3 import Trigger +from ._models_py3 import TriggerList +from ._models_py3 import UpdateDetails +from ._models_py3 import UpdateDownloadProgress +from ._models_py3 import UpdateInstallProgress +from ._models_py3 import UpdateSummary +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UploadCertificateResponse +from ._models_py3 import User +from ._models_py3 import UserAccessRight +from ._models_py3 import UserList -from ._data_box_edge_management_client_enums import ( - AccountType, - AddonState, - AddonType, - AlertSeverity, - AuthenticationType, - AzureContainerDataFormat, - ClientPermissionType, - ContainerStatus, - CreatedByType, - DataBoxEdgeDeviceKind, - DataBoxEdgeDeviceStatus, - DataPolicy, - DayOfWeek, - DeviceType, - DownloadPhase, - EncryptionAlgorithm, - HostPlatformType, - InstallRebootBehavior, - JobStatus, - JobType, - KeyVaultSyncStatus, - KubernetesNodeType, - KubernetesState, - MetricAggregationType, - MetricCategory, - MetricUnit, - MonitoringStatus, - MountType, - MsiIdentityType, - NetworkAdapterDHCPStatus, - NetworkAdapterRDMAStatus, - NetworkAdapterStatus, - NetworkGroup, - NodeStatus, - OrderState, - PlatformType, - PosixComplianceStatus, - ResourceMoveStatus, - RoleStatus, - RoleTypes, - SSLStatus, - ShareAccessProtocol, - ShareAccessType, - ShareStatus, - ShipmentType, - SkuAvailability, - SkuName, - SkuSignupOption, - SkuTier, - SkuVersion, - StorageAccountStatus, - SubscriptionState, - TimeGrain, - TriggerEventType, - UpdateOperation, - UpdateOperationStage, - UpdateStatus, - UpdateType, - UserType, -) +from ._data_box_edge_management_client_enums import AccountType +from ._data_box_edge_management_client_enums import AddonState +from ._data_box_edge_management_client_enums import AddonType +from ._data_box_edge_management_client_enums import AlertSeverity +from ._data_box_edge_management_client_enums import AuthenticationType +from ._data_box_edge_management_client_enums import AzureContainerDataFormat +from ._data_box_edge_management_client_enums import ClientPermissionType +from ._data_box_edge_management_client_enums import ContainerStatus +from ._data_box_edge_management_client_enums import CreatedByType +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceKind +from ._data_box_edge_management_client_enums import DataBoxEdgeDeviceStatus +from ._data_box_edge_management_client_enums import DataPolicy +from ._data_box_edge_management_client_enums import DayOfWeek +from ._data_box_edge_management_client_enums import DeviceType +from ._data_box_edge_management_client_enums import DownloadPhase +from ._data_box_edge_management_client_enums import EncryptionAlgorithm +from ._data_box_edge_management_client_enums import HostPlatformType +from ._data_box_edge_management_client_enums import InstallRebootBehavior +from ._data_box_edge_management_client_enums import JobStatus +from ._data_box_edge_management_client_enums import JobType +from ._data_box_edge_management_client_enums import KeyVaultSyncStatus +from ._data_box_edge_management_client_enums import KubernetesNodeType +from ._data_box_edge_management_client_enums import KubernetesState +from ._data_box_edge_management_client_enums import MetricAggregationType +from ._data_box_edge_management_client_enums import MetricCategory +from ._data_box_edge_management_client_enums import MetricUnit +from ._data_box_edge_management_client_enums import MonitoringStatus +from ._data_box_edge_management_client_enums import MountType +from ._data_box_edge_management_client_enums import MsiIdentityType +from ._data_box_edge_management_client_enums import NetworkAdapterDHCPStatus +from ._data_box_edge_management_client_enums import NetworkAdapterRDMAStatus +from ._data_box_edge_management_client_enums import NetworkAdapterStatus +from ._data_box_edge_management_client_enums import NetworkGroup +from ._data_box_edge_management_client_enums import NodeStatus +from ._data_box_edge_management_client_enums import OrderState +from ._data_box_edge_management_client_enums import PlatformType +from ._data_box_edge_management_client_enums import PosixComplianceStatus +from ._data_box_edge_management_client_enums import ResourceMoveStatus +from ._data_box_edge_management_client_enums import RoleStatus +from ._data_box_edge_management_client_enums import RoleTypes +from ._data_box_edge_management_client_enums import SSLStatus +from ._data_box_edge_management_client_enums import ShareAccessProtocol +from ._data_box_edge_management_client_enums import ShareAccessType +from ._data_box_edge_management_client_enums import ShareStatus +from ._data_box_edge_management_client_enums import ShipmentType +from ._data_box_edge_management_client_enums import SkuAvailability +from ._data_box_edge_management_client_enums import SkuName +from ._data_box_edge_management_client_enums import SkuSignupOption +from ._data_box_edge_management_client_enums import SkuTier +from ._data_box_edge_management_client_enums import SkuVersion +from ._data_box_edge_management_client_enums import StorageAccountStatus +from ._data_box_edge_management_client_enums import SubscriptionState +from ._data_box_edge_management_client_enums import TimeGrain +from ._data_box_edge_management_client_enums import TriggerEventType +from ._data_box_edge_management_client_enums import UpdateOperation +from ._data_box_edge_management_client_enums import UpdateOperationStage +from ._data_box_edge_management_client_enums import UpdateStatus +from ._data_box_edge_management_client_enums import UpdateType +from ._data_box_edge_management_client_enums import UserType +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ARMBaseModel', - 'Addon', - 'AddonList', - 'Address', - 'Alert', - 'AlertErrorDetails', - 'AlertList', - 'ArcAddon', - 'AsymmetricEncryptedSecret', - 'Authentication', - 'AzureContainerInfo', - 'BandwidthSchedule', - 'BandwidthSchedulesList', - 'ClientAccessRight', - 'CloudEdgeManagementRole', - 'CloudErrorBody', - 'CniConfig', - 'ComputeResource', - 'ContactDetails', - 'Container', - 'ContainerList', - 'DCAccessCode', - 'DataBoxEdgeDevice', - 'DataBoxEdgeDeviceExtendedInfo', - 'DataBoxEdgeDeviceExtendedInfoPatch', - 'DataBoxEdgeDeviceList', - 'DataBoxEdgeDevicePatch', - 'DataBoxEdgeMoveRequest', - 'DataBoxEdgeSku', - 'DataBoxEdgeSkuList', - 'EdgeProfile', - 'EdgeProfilePatch', - 'EdgeProfileSubscription', - 'EdgeProfileSubscriptionPatch', - 'EtcdInfo', - 'FileEventTrigger', - 'FileSourceInfo', - 'GenerateCertResponse', - 'ImageRepositoryCredential', - 'IoTAddon', - 'IoTDeviceInfo', - 'IoTEdgeAgentInfo', - 'IoTRole', - 'Ipv4Config', - 'Ipv6Config', - 'Job', - 'JobErrorDetails', - 'JobErrorItem', - 'KubernetesClusterInfo', - 'KubernetesIPConfiguration', - 'KubernetesRole', - 'KubernetesRoleCompute', - 'KubernetesRoleNetwork', - 'KubernetesRoleResources', - 'KubernetesRoleStorage', - 'KubernetesRoleStorageClassInfo', - 'LoadBalancerConfig', - 'MECRole', - 'MetricConfiguration', - 'MetricCounter', - 'MetricCounterSet', - 'MetricDimension', - 'MetricDimensionV1', - 'MetricSpecificationV1', - 'MonitoringMetricConfiguration', - 'MonitoringMetricConfigurationList', - 'MountPointMap', - 'NetworkAdapter', - 'NetworkAdapterPosition', - 'NetworkSettings', - 'Node', - 'NodeInfo', - 'NodeList', - 'Operation', - 'OperationDisplay', - 'OperationsList', - 'Order', - 'OrderList', - 'OrderStatus', - 'PeriodicTimerEventTrigger', - 'PeriodicTimerSourceInfo', - 'RefreshDetails', - 'ResourceIdentity', - 'ResourceMoveDetails', - 'ResourceTypeSku', - 'Role', - 'RoleList', - 'RoleSinkInfo', - 'Secret', - 'SecuritySettings', - 'ServiceSpecification', - 'Share', - 'ShareAccessRight', - 'ShareList', - 'Sku', - 'SkuCost', - 'SkuInformation', - 'SkuInformationList', - 'SkuLocationInfo', - 'StorageAccount', - 'StorageAccountCredential', - 'StorageAccountCredentialList', - 'StorageAccountList', - 'SubscriptionRegisteredFeatures', - 'SymmetricKey', - 'SystemData', - 'TrackingInfo', - 'Trigger', - 'TriggerList', - 'UpdateDetails', - 'UpdateDownloadProgress', - 'UpdateInstallProgress', - 'UpdateSummary', - 'UploadCertificateRequest', - 'UploadCertificateResponse', - 'User', - 'UserAccessRight', - 'UserList', - 'AccountType', - 'AddonState', - 'AddonType', - 'AlertSeverity', - 'AuthenticationType', - 'AzureContainerDataFormat', - 'ClientPermissionType', - 'ContainerStatus', - 'CreatedByType', - 'DataBoxEdgeDeviceKind', - 'DataBoxEdgeDeviceStatus', - 'DataPolicy', - 'DayOfWeek', - 'DeviceType', - 'DownloadPhase', - 'EncryptionAlgorithm', - 'HostPlatformType', - 'InstallRebootBehavior', - 'JobStatus', - 'JobType', - 'KeyVaultSyncStatus', - 'KubernetesNodeType', - 'KubernetesState', - 'MetricAggregationType', - 'MetricCategory', - 'MetricUnit', - 'MonitoringStatus', - 'MountType', - 'MsiIdentityType', - 'NetworkAdapterDHCPStatus', - 'NetworkAdapterRDMAStatus', - 'NetworkAdapterStatus', - 'NetworkGroup', - 'NodeStatus', - 'OrderState', - 'PlatformType', - 'PosixComplianceStatus', - 'ResourceMoveStatus', - 'RoleStatus', - 'RoleTypes', - 'SSLStatus', - 'ShareAccessProtocol', - 'ShareAccessType', - 'ShareStatus', - 'ShipmentType', - 'SkuAvailability', - 'SkuName', - 'SkuSignupOption', - 'SkuTier', - 'SkuVersion', - 'StorageAccountStatus', - 'SubscriptionState', - 'TimeGrain', - 'TriggerEventType', - 'UpdateOperation', - 'UpdateOperationStage', - 'UpdateStatus', - 'UpdateType', - 'UserType', + "ARMBaseModel", + "Addon", + "AddonList", + "Address", + "Alert", + "AlertErrorDetails", + "AlertList", + "ArcAddon", + "AsymmetricEncryptedSecret", + "Authentication", + "AzureContainerInfo", + "BandwidthSchedule", + "BandwidthSchedulesList", + "ClientAccessRight", + "CloudEdgeManagementRole", + "CloudErrorBody", + "CniConfig", + "ComputeResource", + "ContactDetails", + "Container", + "ContainerList", + "DCAccessCode", + "DataBoxEdgeDevice", + "DataBoxEdgeDeviceExtendedInfo", + "DataBoxEdgeDeviceExtendedInfoPatch", + "DataBoxEdgeDeviceList", + "DataBoxEdgeDevicePatch", + "DataBoxEdgeMoveRequest", + "DataBoxEdgeSku", + "DataBoxEdgeSkuList", + "EdgeProfile", + "EdgeProfilePatch", + "EdgeProfileSubscription", + "EdgeProfileSubscriptionPatch", + "EtcdInfo", + "FileEventTrigger", + "FileSourceInfo", + "GenerateCertResponse", + "ImageRepositoryCredential", + "IoTAddon", + "IoTDeviceInfo", + "IoTEdgeAgentInfo", + "IoTRole", + "Ipv4Config", + "Ipv6Config", + "Job", + "JobErrorDetails", + "JobErrorItem", + "KubernetesClusterInfo", + "KubernetesIPConfiguration", + "KubernetesRole", + "KubernetesRoleCompute", + "KubernetesRoleNetwork", + "KubernetesRoleResources", + "KubernetesRoleStorage", + "KubernetesRoleStorageClassInfo", + "LoadBalancerConfig", + "MECRole", + "MetricConfiguration", + "MetricCounter", + "MetricCounterSet", + "MetricDimension", + "MetricDimensionV1", + "MetricSpecificationV1", + "MonitoringMetricConfiguration", + "MonitoringMetricConfigurationList", + "MountPointMap", + "NetworkAdapter", + "NetworkAdapterPosition", + "NetworkSettings", + "Node", + "NodeInfo", + "NodeList", + "Operation", + "OperationDisplay", + "OperationsList", + "Order", + "OrderList", + "OrderStatus", + "PeriodicTimerEventTrigger", + "PeriodicTimerSourceInfo", + "RefreshDetails", + "ResourceIdentity", + "ResourceMoveDetails", + "ResourceTypeSku", + "Role", + "RoleList", + "RoleSinkInfo", + "Secret", + "SecuritySettings", + "ServiceSpecification", + "Share", + "ShareAccessRight", + "ShareList", + "Sku", + "SkuCapability", + "SkuCost", + "SkuInformation", + "SkuInformationList", + "SkuLocationInfo", + "StorageAccount", + "StorageAccountCredential", + "StorageAccountCredentialList", + "StorageAccountList", + "SubscriptionRegisteredFeatures", + "SymmetricKey", + "SystemData", + "TrackingInfo", + "Trigger", + "TriggerList", + "UpdateDetails", + "UpdateDownloadProgress", + "UpdateInstallProgress", + "UpdateSummary", + "UploadCertificateRequest", + "UploadCertificateResponse", + "User", + "UserAccessRight", + "UserList", + "AccountType", + "AddonState", + "AddonType", + "AlertSeverity", + "AuthenticationType", + "AzureContainerDataFormat", + "ClientPermissionType", + "ContainerStatus", + "CreatedByType", + "DataBoxEdgeDeviceKind", + "DataBoxEdgeDeviceStatus", + "DataPolicy", + "DayOfWeek", + "DeviceType", + "DownloadPhase", + "EncryptionAlgorithm", + "HostPlatformType", + "InstallRebootBehavior", + "JobStatus", + "JobType", + "KeyVaultSyncStatus", + "KubernetesNodeType", + "KubernetesState", + "MetricAggregationType", + "MetricCategory", + "MetricUnit", + "MonitoringStatus", + "MountType", + "MsiIdentityType", + "NetworkAdapterDHCPStatus", + "NetworkAdapterRDMAStatus", + "NetworkAdapterStatus", + "NetworkGroup", + "NodeStatus", + "OrderState", + "PlatformType", + "PosixComplianceStatus", + "ResourceMoveStatus", + "RoleStatus", + "RoleTypes", + "SSLStatus", + "ShareAccessProtocol", + "ShareAccessType", + "ShareStatus", + "ShipmentType", + "SkuAvailability", + "SkuName", + "SkuSignupOption", + "SkuTier", + "SkuVersion", + "StorageAccountStatus", + "SubscriptionState", + "TimeGrain", + "TriggerEventType", + "UpdateOperation", + "UpdateOperationStage", + "UpdateStatus", + "UpdateType", + "UserType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_data_box_edge_management_client_enums.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_data_box_edge_management_client_enums.py index 3f2a52eaabf0..81c785c3710d 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_data_box_edge_management_client_enums.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_data_box_edge_management_client_enums.py @@ -6,36 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of storage accessed on the storage account. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of storage accessed on the storage account.""" GENERAL_PURPOSE_STORAGE = "GeneralPurposeStorage" BLOB_STORAGE = "BlobStorage" -class AddonState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Addon Provisioning State - """ + +class AddonState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon Provisioning State.""" INVALID = "Invalid" CREATING = "Creating" @@ -45,47 +28,47 @@ class AddonState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETING = "Deleting" -class AddonType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Addon type. - """ + +class AddonType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Addon type.""" IOT_EDGE = "IotEdge" ARC_FOR_KUBERNETES = "ArcForKubernetes" -class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Severity of the alert. - """ + +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert.""" INFORMATIONAL = "Informational" WARNING = "Warning" CRITICAL = "Critical" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The authentication type. - """ + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication type.""" INVALID = "Invalid" AZURE_ACTIVE_DIRECTORY = "AzureActiveDirectory" -class AzureContainerDataFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Storage format used for the file represented by the share. - """ + +class AzureContainerDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage format used for the file represented by the share.""" BLOCK_BLOB = "BlockBlob" PAGE_BLOB = "PageBlob" AZURE_FILE = "AzureFile" -class ClientPermissionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed for the client. - """ + +class ClientPermissionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed for the client.""" NO_ACCESS = "NoAccess" READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the container. - """ + +class ContainerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the container.""" OK = "OK" OFFLINE = "Offline" @@ -93,27 +76,27 @@ class ContainerStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DataBoxEdgeDeviceKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The etag for the devices. - """ + +class DataBoxEdgeDeviceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The etag for the devices.""" AZURE_DATA_BOX_GATEWAY = "AzureDataBoxGateway" AZURE_STACK_EDGE = "AzureStackEdge" AZURE_STACK_HUB = "AzureStackHub" AZURE_MODULAR_DATA_CENTRE = "AzureModularDataCentre" -class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the Data Box Edge/Gateway device. - """ + +class DataBoxEdgeDeviceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the Data Box Edge/Gateway device.""" READY_TO_SETUP = "ReadyToSetup" ONLINE = "Online" @@ -123,14 +106,16 @@ class DataBoxEdgeDeviceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum PARTIALLY_DISCONNECTED = "PartiallyDisconnected" MAINTENANCE = "Maintenance" -class DataPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Data policy of the share. - """ + +class DataPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data policy of the share.""" CLOUD = "Cloud" LOCAL = "Local" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DayOfWeek.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -140,47 +125,47 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DeviceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the Data Box Edge/Gateway device. - """ + +class DeviceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the Data Box Edge/Gateway device.""" DATA_BOX_EDGE_DEVICE = "DataBoxEdgeDevice" -class DownloadPhase(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The download phase. - """ + +class DownloadPhase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The download phase.""" UNKNOWN = "Unknown" INITIALIZING = "Initializing" DOWNLOADING = "Downloading" VERIFYING = "Verifying" -class EncryptionAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The algorithm used to encrypt "Value". - """ + +class EncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The algorithm used to encrypt "Value".""" NONE = "None" AES256 = "AES256" RSAES_PKCS1_V1_5 = "RSAES_PKCS1_v_1_5" -class HostPlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Platform where the runtime is hosted. - """ + +class HostPlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Platform where the runtime is hosted.""" KUBERNETES_CLUSTER = "KubernetesCluster" LINUX_VM = "LinuxVM" -class InstallRebootBehavior(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if updates are available and at least one of the updates needs a reboot. - """ + +class InstallRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if updates are available and at least one of the updates needs a reboot.""" NEVER_REBOOTS = "NeverReboots" REQUIRES_REBOOT = "RequiresReboot" REQUEST_REBOOT = "RequestReboot" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the job. - """ + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the job.""" INVALID = "Invalid" RUNNING = "Running" @@ -190,9 +175,9 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PAUSED = "Paused" SCHEDULED = "Scheduled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the job. - """ + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" INVALID = "Invalid" SCAN_FOR_UPDATES = "ScanForUpdates" @@ -204,7 +189,8 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESTORE = "Restore" TRIGGER_SUPPORT_PACKAGE = "TriggerSupportPackage" -class KeyVaultSyncStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class KeyVaultSyncStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """For changing or to initiate the resync to key-vault set the status to KeyVaultSyncPending, rest of the status will not be applicable. """ @@ -216,17 +202,17 @@ class KeyVaultSyncStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): KEY_VAULT_SYNCING = "KeyVaultSyncing" KEY_VAULT_NOT_SYNCED = "KeyVaultNotSynced" -class KubernetesNodeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Node type - Master/Worker - """ + +class KubernetesNodeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Node type - Master/Worker.""" INVALID = "Invalid" MASTER = "Master" WORKER = "Worker" -class KubernetesState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """State of Kubernetes deployment - """ + +class KubernetesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of Kubernetes deployment.""" INVALID = "Invalid" CREATING = "Creating" @@ -236,9 +222,9 @@ class KubernetesState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETING = "Deleting" -class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric aggregation type. - """ + +class MetricAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric aggregation type.""" NOT_SPECIFIED = "NotSpecified" NONE = "None" @@ -248,16 +234,16 @@ class MetricAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) TOTAL = "Total" COUNT = "Count" -class MetricCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric category. - """ + +class MetricCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric category.""" CAPACITY = "Capacity" TRANSACTION = "Transaction" -class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Metric units. - """ + +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Metric units.""" NOT_SPECIFIED = "NotSpecified" PERCENT = "Percent" @@ -268,60 +254,60 @@ class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BYTES_PER_SECOND = "BytesPerSecond" COUNT_PER_SECOND = "CountPerSecond" -class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current monitoring status of the share. - """ + +class MonitoringStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current monitoring status of the share.""" ENABLED = "Enabled" DISABLED = "Disabled" -class MountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Mounting type. - """ + +class MountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Mounting type.""" VOLUME = "Volume" HOST_PATH = "HostPath" -class MsiIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Identity type - """ + +class MsiIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" -class NetworkAdapterDHCPStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter has DHCP enabled. - """ + +class NetworkAdapterDHCPStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter has DHCP enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" -class NetworkAdapterRDMAStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is RDMA capable. - """ + +class NetworkAdapterRDMAStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is RDMA capable.""" INCAPABLE = "Incapable" CAPABLE = "Capable" -class NetworkAdapterStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Value indicating whether this adapter is valid. - """ + +class NetworkAdapterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Value indicating whether this adapter is valid.""" INACTIVE = "Inactive" ACTIVE = "Active" -class NetworkGroup(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The network group. - """ + +class NetworkGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The network group.""" NONE = "None" NON_RDMA = "NonRDMA" RDMA = "RDMA" -class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current status of the individual node - """ + +class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current status of the individual node.""" UNKNOWN = "Unknown" UP = "Up" @@ -329,9 +315,9 @@ class NodeStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REBOOTING = "Rebooting" SHUTTING_DOWN = "ShuttingDown" -class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the order as per the allowed status types. - """ + +class OrderState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the order as per the allowed status types.""" UNTRACKED = "Untracked" AWAITING_FULFILLMENT = "AwaitingFulfillment" @@ -351,37 +337,39 @@ class OrderState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PICKUP_COMPLETED = "PickupCompleted" AWAITING_DROP = "AwaitingDrop" -class PlatformType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Host OS supported by the Arc addon. - """ + +class PlatformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host OS supported by the Arc addon.""" WINDOWS = "Windows" LINUX = "Linux" -class PosixComplianceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """If provisioned storage is posix compliant. - """ + +class PosixComplianceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """If provisioned storage is posix compliant.""" INVALID = "Invalid" ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceMoveStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Denotes whether move operation is in progress - """ + +class ResourceMoveStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Denotes whether move operation is in progress.""" NONE = "None" RESOURCE_MOVE_IN_PROGRESS = "ResourceMoveInProgress" RESOURCE_MOVE_FAILED = "ResourceMoveFailed" -class RoleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Local Edge Management Status - """ + +class RoleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Local Edge Management Status.""" ENABLED = "Enabled" DISABLED = "Disabled" -class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RoleTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleTypes.""" IOT = "IOT" ASA = "ASA" @@ -391,24 +379,24 @@ class RoleTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CLOUD_EDGE_MANAGEMENT = "CloudEdgeManagement" KUBERNETES = "Kubernetes" -class ShareAccessProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Access protocol to be used by the share. - """ + +class ShareAccessProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access protocol to be used by the share.""" SMB = "SMB" NFS = "NFS" -class ShareAccessType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of access to be allowed on the share for this user. - """ + +class ShareAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of access to be allowed on the share for this user.""" CHANGE = "Change" READ = "Read" CUSTOM = "Custom" -class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the share. - """ + +class ShareStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the share.""" OFFLINE = "Offline" UNKNOWN = "Unknown" @@ -416,22 +404,24 @@ class ShareStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class ShipmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class ShipmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ShipmentType.""" NOT_APPLICABLE = "NotApplicable" SHIPPED_TO_CUSTOMER = "ShippedToCustomer" SELF_PICKUP = "SelfPickup" -class SkuAvailability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Links to the next set of results - """ + +class SkuAvailability(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Links to the next set of results.""" AVAILABLE = "Available" UNAVAILABLE = "Unavailable" -class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku name. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku name.""" GATEWAY = "Gateway" EDGE = "Edge" @@ -459,36 +449,36 @@ class SkuName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RDC = "RDC" MANAGEMENT = "Management" -class SkuSignupOption(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Sku can be signed up by customer or not. - """ + +class SkuSignupOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sku can be signed up by customer or not.""" NONE = "None" AVAILABLE = "Available" -class SkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The Sku tier. - """ + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Sku tier.""" STANDARD = "Standard" -class SkuVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Availability of the Sku as preview/stable. - """ + +class SkuVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Availability of the Sku as preview/stable.""" STABLE = "Stable" PREVIEW = "Preview" -class SSLStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Signifies whether SSL needs to be enabled or not. - """ + +class SSLStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Signifies whether SSL needs to be enabled or not.""" ENABLED = "Enabled" DISABLED = "Disabled" -class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current status of the storage account - """ + +class StorageAccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current status of the storage account.""" OK = "OK" OFFLINE = "Offline" @@ -496,7 +486,9 @@ class StorageAccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UPDATING = "Updating" NEEDS_ATTENTION = "NeedsAttention" -class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SubscriptionState.""" REGISTERED = "Registered" WARNED = "Warned" @@ -504,7 +496,9 @@ class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETED = "Deleted" UNREGISTERED = "Unregistered" -class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class TimeGrain(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TimeGrain.""" PT1_M = "PT1M" PT5_M = "PT5M" @@ -515,25 +509,25 @@ class TimeGrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PT12_H = "PT12H" PT1_D = "PT1D" -class TriggerEventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Trigger Kind. - """ + +class TriggerEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trigger Kind.""" FILE_EVENT = "FileEvent" PERIODIC_TIMER_EVENT = "PeriodicTimerEvent" -class UpdateOperation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current update operation. - """ + +class UpdateOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current update operation.""" NONE = "None" SCAN = "Scan" DOWNLOAD = "Download" INSTALL = "Install" -class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current stage of the update operation. - """ + +class UpdateOperationStage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current stage of the update operation.""" UNKNOWN = "Unknown" INITIAL = "Initial" @@ -553,9 +547,9 @@ class UpdateOperationStage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESCAN_COMPLETE = "RescanComplete" RESCAN_FAILED = "RescanFailed" -class UpdateStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the update. - """ + +class UpdateStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the update.""" DOWNLOAD_PENDING = "DownloadPending" DOWNLOAD_STARTED = "DownloadStarted" @@ -563,17 +557,17 @@ class UpdateStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INSTALL_STARTED = "InstallStarted" INSTALL_COMPLETED = "InstallCompleted" -class UpdateType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of the Update - """ + +class UpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the Update.""" SOFTWARE = "Software" KUBERNETES = "Kubernetes" FIRMWARE = "Firmware" -class UserType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of the user. - """ + +class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the user.""" SHARE = "Share" LOCAL_MANAGEMENT = "LocalManagement" diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_models.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_models.py deleted file mode 100644 index ed1d3c45a4dc..000000000000 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_models.py +++ /dev/null @@ -1,5195 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class ARMBaseModel(msrest.serialization.Model): - """Represents the base class for all object models. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Addon(ARMBaseModel): - """Role Addon. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ArcAddon, IoTAddon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - _subtype_map = { - 'kind': {'ArcForKubernetes': 'ArcAddon', 'IotEdge': 'IoTAddon'} - } - - def __init__( - self, - **kwargs - ): - super(Addon, self).__init__(**kwargs) - self.kind = 'Addon' # type: str - self.system_data = None - - -class AddonList(msrest.serialization.Model): - """Collection of all the Role addon on the Azure Stack Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Address(msrest.serialization.Model): - """The shipping address of the customer. - - All required parameters must be populated in order to send to Azure. - - :param address_line1: The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: The postal code. - :type postal_code: str - :param city: The city name. - :type city: str - :param state: The state name. - :type state: str - :param country: Required. The country name. - :type country: str - """ - - _validation = { - 'country': {'required': True}, - } - - _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Address, self).__init__(**kwargs) - self.address_line1 = kwargs.get('address_line1', None) - self.address_line2 = kwargs.get('address_line2', None) - self.address_line3 = kwargs.get('address_line3', None) - self.postal_code = kwargs.get('postal_code', None) - self.city = kwargs.get('city', None) - self.state = kwargs.get('state', None) - self.country = kwargs['country'] - - -class Alert(ARMBaseModel): - """Alert on the data box edge/gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Alert generated in the resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :ivar title: Alert title. - :vartype title: str - :ivar alert_type: Alert type. - :vartype alert_type: str - :ivar appeared_at_date_time: UTC time when the alert appeared. - :vartype appeared_at_date_time: ~datetime.datetime - :ivar recommendation: Alert recommendation. - :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", - "Critical". - :vartype severity: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AlertSeverity - :ivar error_details: Error details of the alert. - :vartype error_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AlertErrorDetails - :ivar detailed_information: Alert details. - :vartype detailed_information: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) - self.system_data = None - self.title = None - self.alert_type = None - self.appeared_at_date_time = None - self.recommendation = None - self.severity = None - self.error_details = None - self.detailed_information = None - - -class AlertErrorDetails(msrest.serialization.Model): - """Error details for the alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_code: Error code. - :vartype error_code: str - :ivar error_message: Error Message. - :vartype error_message: str - :ivar occurrences: Number of occurrences. - :vartype occurrences: int - """ - - _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, - } - - _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) - self.error_code = None - self.error_message = None - self.occurrences = None - - -class AlertList(msrest.serialization.Model): - """Collection of alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Alert] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ArcAddon(Addon): - """Arc Addon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param subscription_id: Required. Arc resource subscription Id. - :type subscription_id: str - :param resource_group_name: Required. Arc resource group name. - :type resource_group_name: str - :param resource_name: Required. Arc resource Name. - :type resource_name: str - :param resource_location: Required. Arc resource location. - :type resource_location: str - :ivar version: Arc resource version. - :vartype version: str - :ivar host_platform: Host OS supported by the Arc addon. Possible values include: "Windows", - "Linux". - :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'subscription_id': {'required': True}, - 'resource_group_name': {'required': True}, - 'resource_name': {'required': True}, - 'resource_location': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'properties.resourceGroupName', 'type': 'str'}, - 'resource_name': {'key': 'properties.resourceName', 'type': 'str'}, - 'resource_location': {'key': 'properties.resourceLocation', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArcAddon, self).__init__(**kwargs) - self.kind = 'ArcForKubernetes' # type: str - self.subscription_id = kwargs['subscription_id'] - self.resource_group_name = kwargs['resource_group_name'] - self.resource_name = kwargs['resource_name'] - self.resource_location = kwargs['resource_location'] - self.version = None - self.host_platform = None - self.host_platform_type = None - self.provisioning_state = None - - -class AsymmetricEncryptedSecret(msrest.serialization.Model): - """Represent the secrets intended for encryption with asymmetric key pair. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the - value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EncryptionAlgorithm - """ - - _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) - self.value = kwargs['value'] - self.encryption_cert_thumbprint = kwargs.get('encryption_cert_thumbprint', None) - self.encryption_algorithm = kwargs['encryption_algorithm'] - - -class Authentication(msrest.serialization.Model): - """Authentication mechanism for IoT devices. - - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SymmetricKey - """ - - _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, - } - - def __init__( - self, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) - self.symmetric_key = kwargs.get('symmetric_key', None) - - -class AzureContainerInfo(msrest.serialization.Model): - """Azure container mapping of the endpoint. - - All required parameters must be populated in order to send to Azure. - - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AzureContainerDataFormat - """ - - _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, - } - - _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureContainerInfo, self).__init__(**kwargs) - self.storage_account_credential_id = kwargs['storage_account_credential_id'] - self.container_name = kwargs['container_name'] - self.data_format = kwargs['data_format'] - - -class BandwidthSchedule(ARMBaseModel): - """The bandwidth schedule details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Bandwidth object related to ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DayOfWeek] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedule, self).__init__(**kwargs) - self.system_data = None - self.start = kwargs['start'] - self.stop = kwargs['stop'] - self.rate_in_mbps = kwargs['rate_in_mbps'] - self.days = kwargs['days'] - - -class BandwidthSchedulesList(msrest.serialization.Model): - """The collection of bandwidth schedules. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of bandwidth schedules. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ClientAccessRight(msrest.serialization.Model): - """The mapping between a particular client IP and the type of access client has on the NFS share. - - All required parameters must be populated in order to send to Azure. - - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ClientPermissionType - """ - - _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, - } - - _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) - self.client = kwargs['client'] - self.access_permission = kwargs['access_permission'] - - -class Role(ARMBaseModel): - """Compute role. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - _subtype_map = { - 'kind': {'CloudEdgeManagement': 'CloudEdgeManagementRole', 'IOT': 'IoTRole', 'Kubernetes': 'KubernetesRole', 'MEC': 'MECRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str - self.system_data = None - - -class CloudEdgeManagementRole(Role): - """CloudEdgeManagementRole role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :ivar local_management_status: Local Edge Management Status. Possible values include: - "Enabled", "Disabled". - :vartype local_management_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus - :ivar edge_profile: Edge Profile of the resource. - :vartype edge_profile: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfile - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'local_management_status': {'readonly': True}, - 'edge_profile': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'local_management_status': {'key': 'properties.localManagementStatus', 'type': 'str'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudEdgeManagementRole, self).__init__(**kwargs) - self.kind = 'CloudEdgeManagement' # type: str - self.local_management_status = None - self.edge_profile = None - self.role_status = kwargs.get('role_status', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.CloudErrorBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class CniConfig(msrest.serialization.Model): - """Cni configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Cni type. - :vartype type: str - :ivar version: Cni version. - :vartype version: str - :ivar pod_subnet: Pod Subnet. - :vartype pod_subnet: str - :ivar service_subnet: Service subnet. - :vartype service_subnet: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - 'pod_subnet': {'readonly': True}, - 'service_subnet': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'pod_subnet': {'key': 'podSubnet', 'type': 'str'}, - 'service_subnet': {'key': 'serviceSubnet', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CniConfig, self).__init__(**kwargs) - self.type = None - self.version = None - self.pod_subnet = None - self.service_subnet = None - - -class ComputeResource(msrest.serialization.Model): - """Compute infrastructure Resource. - - All required parameters must be populated in order to send to Azure. - - :param processor_count: Required. Processor count. - :type processor_count: int - :param memory_in_gb: Required. Memory in GB. - :type memory_in_gb: long - """ - - _validation = { - 'processor_count': {'required': True}, - 'memory_in_gb': {'required': True}, - } - - _attribute_map = { - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeResource, self).__init__(**kwargs) - self.processor_count = kwargs['processor_count'] - self.memory_in_gb = kwargs['memory_in_gb'] - - -class ContactDetails(msrest.serialization.Model): - """Contains all the contact details of the customer. - - All required parameters must be populated in order to send to Azure. - - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] - """ - - _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, - } - - _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) - self.contact_person = kwargs['contact_person'] - self.company_name = kwargs['company_name'] - self.phone = kwargs['phone'] - self.email_list = kwargs['email_list'] - - -class Container(ARMBaseModel): - """Represents a container on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Container in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". - :vartype container_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AzureContainerDataFormat - :ivar refresh_details: Details of the refresh job on this container. - :vartype refresh_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RefreshDetails - :ivar created_date_time: The UTC time when container got created. - :vartype created_date_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Container, self).__init__(**kwargs) - self.system_data = None - self.container_status = None - self.data_format = kwargs['data_format'] - self.refresh_details = None - self.created_date_time = None - - -class ContainerList(msrest.serialization.Model): - """Collection of all the containers on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of containers. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevice(ARMBaseModel): - """The Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure - geographical region (for example, West US, East US, or Southeast Asia). The geographical region - of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceIdentity - :ivar kind: The etag for the devices. Possible values include: "AzureDataBoxGateway", - "AzureStackEdge", "AzureStackHub", "AzureModularDataCentre". - :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceKind - :ivar system_data: DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceStatus - :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. - :vartype serial_number: str - :ivar description: The Description of the Data Box Edge/Gateway device. - :vartype description: str - :ivar model_description: The description of the Data Box Edge/Gateway device model. - :vartype model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". - :vartype device_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DeviceType - :ivar friendly_name: The Data Box Edge/Gateway device name. - :vartype friendly_name: str - :ivar culture: The Data Box Edge/Gateway device culture. - :vartype culture: str - :ivar device_model: The Data Box Edge/Gateway device model. - :vartype device_model: str - :ivar device_software_version: The Data Box Edge/Gateway device software version. - :vartype device_software_version: str - :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long - :ivar time_zone: The Data Box Edge/Gateway device timezone. - :vartype time_zone: str - :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). - :vartype device_hcs_version: str - :ivar configured_role_types: Type of compute roles configured. - :vartype configured_role_types: list[str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes] - :ivar node_count: The number of nodes in the cluster. - :vartype node_count: int - :ivar resource_move_details: The details of the move operation on this resource. - :vartype resource_move_details: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceMoveDetails - :ivar edge_profile: The details of Edge Profile for this resource. - :vartype edge_profile: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfile - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'system_data': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'description': {'readonly': True}, - 'model_description': {'readonly': True}, - 'device_type': {'readonly': True}, - 'friendly_name': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'edge_profile': {'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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - 'resource_move_details': {'key': 'properties.resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.sku = kwargs.get('sku', None) - self.etag = kwargs.get('etag', None) - self.identity = kwargs.get('identity', None) - self.kind = None - self.system_data = None - self.data_box_edge_device_status = kwargs.get('data_box_edge_device_status', None) - self.serial_number = None - self.description = None - self.model_description = None - self.device_type = None - self.friendly_name = None - self.culture = None - self.device_model = None - self.device_software_version = None - self.device_local_capacity = None - self.time_zone = None - self.device_hcs_version = None - self.configured_role_types = None - self.node_count = None - self.resource_move_details = None - self.edge_profile = None - - -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): - """The extended Info of the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to - encrypt any secret. - :type encryption_key: str - :ivar resource_key: The Resource ID of the Resource. - :vartype resource_key: str - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key - Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client - Key Vault. - :type channel_integrity_key_version: str - :param key_vault_sync_status: Key vault sync status. Possible values include: "KeyVaultSynced", - "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", "KeyVaultSyncing", - "KeyVaultNotSynced". - :type key_vault_sync_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KeyVaultSyncStatus - :ivar device_secrets: Device secrets, will be returned only with ODataFilter - $expand=deviceSecrets. - :vartype device_secrets: dict[str, ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Secret] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - 'device_secrets': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - 'client_secret_store_id': {'key': 'properties.clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'properties.clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'properties.channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'properties.channelIntegrityKeyVersion', 'type': 'str'}, - 'key_vault_sync_status': {'key': 'properties.keyVaultSyncStatus', 'type': 'str'}, - 'device_secrets': {'key': 'properties.deviceSecrets', 'type': '{Secret}'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) - self.encryption_key_thumbprint = kwargs.get('encryption_key_thumbprint', None) - self.encryption_key = kwargs.get('encryption_key', None) - self.resource_key = None - self.client_secret_store_id = kwargs.get('client_secret_store_id', None) - self.client_secret_store_url = kwargs.get('client_secret_store_url', None) - self.channel_integrity_key_name = kwargs.get('channel_integrity_key_name', None) - self.channel_integrity_key_version = kwargs.get('channel_integrity_key_version', None) - self.key_vault_sync_status = kwargs.get('key_vault_sync_status', None) - self.device_secrets = None - - -class DataBoxEdgeDeviceExtendedInfoPatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device extended info patch. - - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key - Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client - Key Vault. - :type channel_integrity_key_version: str - :param sync_status: For changing or to initiate the resync to key-vault set the status to - KeyVaultSyncPending, rest of the status will not be applicable. Possible values include: - "KeyVaultSynced", "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", - "KeyVaultSyncing", "KeyVaultNotSynced". - :type sync_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KeyVaultSyncStatus - """ - - _attribute_map = { - 'client_secret_store_id': {'key': 'clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'channelIntegrityKeyVersion', 'type': 'str'}, - 'sync_status': {'key': 'syncStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceExtendedInfoPatch, self).__init__(**kwargs) - self.client_secret_store_id = kwargs.get('client_secret_store_id', None) - self.client_secret_store_url = kwargs.get('client_secret_store_url', None) - self.channel_integrity_key_name = kwargs.get('channel_integrity_key_name', None) - self.channel_integrity_key_version = kwargs.get('channel_integrity_key_version', None) - self.sync_status = kwargs.get('sync_status', None) - - -class DataBoxEdgeDeviceList(msrest.serialization.Model): - """The collection of Data Box Edge/Gateway devices. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Data Box Edge/Gateway devices. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DataBoxEdgeDevicePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway device patch. - - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceIdentity - :param edge_profile: Edge Profile property of the Data Box Edge/Gateway device. - :type edge_profile: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfilePatch - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfilePatch'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.identity = kwargs.get('identity', None) - self.edge_profile = kwargs.get('edge_profile', None) - - -class DataBoxEdgeMoveRequest(msrest.serialization.Model): - """Resource Move details. - - All required parameters must be populated in order to send to Azure. - - :param target_resource_group: Required. Target resource group ARMId. - :type target_resource_group: str - :param resources: Required. List of resources to be moved. - :type resources: list[str] - """ - - _validation = { - 'target_resource_group': {'required': True}, - 'resources': {'required': True}, - } - - _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeMoveRequest, self).__init__(**kwargs) - self.target_resource_group = kwargs['target_resource_group'] - self.resources = kwargs['resources'] - - -class DataBoxEdgeSku(msrest.serialization.Model): - """The Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", - "EP2_256_2T4_W", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC", "Management". - :vartype name: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuName - :ivar kind: The Sku kind. - :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". - :vartype tier: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuTier - :ivar size: The Sku kind. - :vartype size: str - :ivar family: The Sku family. - :vartype family: str - :ivar locations: Availability of the Sku for the region. - :vartype locations: list[str] - :ivar api_versions: The API versions in which Sku is available. - :vartype api_versions: list[str] - :ivar location_info: Availability of the Sku for the location/zone/site. - :vartype location_info: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuLocationInfo] - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuCost] - :ivar signup_option: Sku can be signed up by customer or not. Possible values include: "None", - "Available". - :vartype signup_option: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuSignupOption - :ivar version: Availability of the Sku as preview/stable. Possible values include: "Stable", - "Preview". - :vartype version: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuVersion - :ivar availability: Links to the next set of results. Possible values include: "Available", - "Unavailable". - :vartype availability: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuAvailability - :ivar shipment_types: List of Shipment Types supported by this SKU. - :vartype shipment_types: list[str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShipmentType] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - 'shipment_types': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, - 'shipment_types': {'key': 'shipmentTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) - self.resource_type = None - self.name = None - self.kind = None - self.tier = None - self.size = None - self.family = None - self.locations = None - self.api_versions = None - self.location_info = None - self.costs = None - self.signup_option = None - self.version = None - self.availability = None - self.shipment_types = None - - -class DataBoxEdgeSkuList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceType Sku. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DCAccessCode(msrest.serialization.Model): - """DC Access code in the case of Self Managed Shipping. - - :param auth_code: DCAccess Code for the Self Managed shipment. - :type auth_code: str - """ - - _attribute_map = { - 'auth_code': {'key': 'properties.authCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DCAccessCode, self).__init__(**kwargs) - self.auth_code = kwargs.get('auth_code', None) - - -class EdgeProfile(msrest.serialization.Model): - """Details about Edge Profile for the resource. - - :param subscription: Edge Profile Subscription. - :type subscription: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfileSubscription - """ - - _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscription'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfile, self).__init__(**kwargs) - self.subscription = kwargs.get('subscription', None) - - -class EdgeProfilePatch(msrest.serialization.Model): - """The Data Box Edge/Gateway Edge Profile patch. - - :param subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. - :type subscription: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfileSubscriptionPatch - """ - - _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscriptionPatch'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfilePatch, self).__init__(**kwargs) - self.subscription = kwargs.get('subscription', None) - - -class EdgeProfileSubscription(msrest.serialization.Model): - """Subscription details for the Edge Profile. - - :param registration_id: Edge Subscription Registration ID. - :type registration_id: str - :param id: ARM ID of the subscription. - :type id: str - :param state: Possible values include: "Registered", "Warned", "Suspended", "Deleted", - "Unregistered". - :type state: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SubscriptionState - :param registration_date: - :type registration_date: str - :param subscription_id: - :type subscription_id: str - :param tenant_id: - :type tenant_id: str - :param location_placement_id: - :type location_placement_id: str - :param quota_id: - :type quota_id: str - :param serialized_details: - :type serialized_details: str - :param registered_features: - :type registered_features: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SubscriptionRegisteredFeatures] - """ - - _attribute_map = { - 'registration_id': {'key': 'registrationId', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'registration_date': {'key': 'registrationDate', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'location_placement_id': {'key': 'properties.locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'properties.quotaId', 'type': 'str'}, - 'serialized_details': {'key': 'properties.serializedDetails', 'type': 'str'}, - 'registered_features': {'key': 'properties.registeredFeatures', 'type': '[SubscriptionRegisteredFeatures]'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfileSubscription, self).__init__(**kwargs) - self.registration_id = kwargs.get('registration_id', None) - self.id = kwargs.get('id', None) - self.state = kwargs.get('state', None) - self.registration_date = kwargs.get('registration_date', None) - self.subscription_id = kwargs.get('subscription_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.location_placement_id = kwargs.get('location_placement_id', None) - self.quota_id = kwargs.get('quota_id', None) - self.serialized_details = kwargs.get('serialized_details', None) - self.registered_features = kwargs.get('registered_features', None) - - -class EdgeProfileSubscriptionPatch(msrest.serialization.Model): - """The Data Box Edge/Gateway Edge Profile Subscription patch. - - :param id: The path ID that uniquely identifies the subscription of the edge profile. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EdgeProfileSubscriptionPatch, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class EtcdInfo(msrest.serialization.Model): - """Etcd configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Etcd type. - :vartype type: str - :ivar version: Etcd version. - :vartype version: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EtcdInfo, self).__init__(**kwargs) - self.type = None - self.version = None - - -class Trigger(ARMBaseModel): - """Trigger details. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerEventType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - } - - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } - - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) - self.system_data = None - self.kind = 'Trigger' # type: str - - -class FileEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class FileSourceInfo(msrest.serialization.Model): - """File source details. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. File share ID. - :type share_id: str - """ - - _validation = { - 'share_id': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - - -class GenerateCertResponse(msrest.serialization.Model): - """Used in activation key generation flow. - - :param public_key: Gets or sets base64 encoded certificate raw data, - this is the public part needed to be uploaded to cert vault. - :type public_key: str - :param private_key: Gets or sets base64 encoded private part of the certificate, - needed to form the activation key. - :type private_key: str - :param expiry_time_in_utc: Gets or sets expiry time in UTC. - :type expiry_time_in_utc: str - """ - - _attribute_map = { - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'expiry_time_in_utc': {'key': 'expiryTimeInUTC', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GenerateCertResponse, self).__init__(**kwargs) - self.public_key = kwargs.get('public_key', None) - self.private_key = kwargs.get('private_key', None) - self.expiry_time_in_utc = kwargs.get('expiry_time_in_utc', None) - - -class ImageRepositoryCredential(msrest.serialization.Model): - """Image repository credential. - - All required parameters must be populated in order to send to Azure. - - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, - } - - _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(ImageRepositoryCredential, self).__init__(**kwargs) - self.image_repository_url = kwargs['image_repository_url'] - self.user_name = kwargs['user_name'] - self.password = kwargs.get('password', None) - - -class IoTAddon(Addon): - """IoT Addon. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonType - :ivar system_data: Addon type. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param io_t_device_details: Required. IoT device metadata to which appliance needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: Required. IoT edge device to which the IoT Addon needs to be - configured. - :type io_t_edge_device_details: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo - :ivar version: Version of IoT running on the appliance. - :vartype version: str - :ivar host_platform: Host OS supported by the IoT addon. Possible values include: "Windows", - "Linux". - :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'io_t_device_details': {'required': True}, - 'io_t_edge_device_details': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTAddon, self).__init__(**kwargs) - self.kind = 'IotEdge' # type: str - self.io_t_device_details = kwargs['io_t_device_details'] - self.io_t_edge_device_details = kwargs['io_t_edge_device_details'] - self.version = None - self.host_platform = None - self.host_platform_type = None - self.provisioning_state = None - - -class IoTDeviceInfo(msrest.serialization.Model): - """Metadata of IoT device/IoT Edge device to be configured. - - All required parameters must be populated in order to send to Azure. - - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Authentication - """ - - _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTDeviceInfo, self).__init__(**kwargs) - self.device_id = kwargs['device_id'] - self.io_t_host_hub = kwargs['io_t_host_hub'] - self.io_t_host_hub_id = kwargs.get('io_t_host_hub_id', None) - self.authentication = kwargs.get('authentication', None) - - -class IoTEdgeAgentInfo(msrest.serialization.Model): - """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. - - All required parameters must be populated in order to send to Azure. - - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ImageRepositoryCredential - """ - - _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, - } - - _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) - self.image_name = kwargs['image_name'] - self.tag = kwargs['tag'] - self.image_repository = kwargs.get('image_repository', None) - - -class IoTRole(Role): - """Compute role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", - "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot - runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.HostPlatformType - :param compute_resource: Resource allocation. - :type compute_resource: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ComputeResource - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'compute_resource': {'key': 'properties.computeResource', 'type': 'ComputeResource'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.io_t_device_details = kwargs.get('io_t_device_details', None) - self.io_t_edge_device_details = kwargs.get('io_t_edge_device_details', None) - self.share_mappings = kwargs.get('share_mappings', None) - self.io_t_edge_agent_info = kwargs.get('io_t_edge_agent_info', None) - self.host_platform_type = None - self.compute_resource = kwargs.get('compute_resource', None) - self.role_status = kwargs.get('role_status', None) - - -class Ipv4Config(msrest.serialization.Model): - """Details related to the IPv4 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv4 address of the network adapter. - :vartype ip_address: str - :ivar subnet: The IPv4 subnet of the network adapter. - :vartype subnet: str - :ivar gateway: The IPv4 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) - self.ip_address = None - self.subnet = None - self.gateway = None - - -class Ipv6Config(msrest.serialization.Model): - """Details related to the IPv6 address configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ip_address: The IPv6 address of the network adapter. - :vartype ip_address: str - :ivar prefix_length: The IPv6 prefix of the network adapter. - :vartype prefix_length: int - :ivar gateway: The IPv6 gateway of the network adapter. - :vartype gateway: str - """ - - _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, - } - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) - self.ip_address = None - self.prefix_length = None - self.gateway = None - - -class Job(msrest.serialization.Model): - """A device job. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The name of the object. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobStatus - :ivar start_time: The UTC date and time at which the job started. - :vartype start_time: ~datetime.datetime - :ivar end_time: The UTC date and time at which the job completed. - :vartype end_time: ~datetime.datetime - :ivar percent_complete: The percentage of the job that is complete. - :vartype percent_complete: int - :ivar error: The error details. - :vartype error: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", - "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer", "Backup", "Restore", - "TriggerSupportPackage". - :vartype job_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", - "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", - "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". - :vartype current_stage: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateOperationStage - :ivar download_progress: The download progress. - :vartype download_progress: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateDownloadProgress - :ivar install_progress: The install progress. - :vartype install_progress: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateInstallProgress - :ivar total_refresh_errors: Total number of errors encountered during the refresh process. - :vartype total_refresh_errors: int - :ivar error_manifest_file: Local share/remote container relative path to the error manifest - file of the refresh. - :vartype error_manifest_file: str - :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. - :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Job, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_time = None - self.end_time = None - self.percent_complete = None - self.error = None - self.job_type = None - self.current_stage = None - self.download_progress = None - self.install_progress = None - self.total_refresh_errors = None - self.error_manifest_file = None - self.refreshed_entity_id = None - self.folder = kwargs.get('folder', None) - - -class JobErrorDetails(msrest.serialization.Model): - """The job error information containing the list of job errors. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar error_details: The error details. - :vartype error_details: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobErrorItem] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) - self.error_details = None - self.code = None - self.message = None - - -class JobErrorItem(msrest.serialization.Model): - """The job error items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendations: The recommended actions. - :vartype recommendations: list[str] - :ivar code: The code intended for programmatic access. - :vartype code: str - :ivar message: The message that describes the error in detail. - :vartype message: str - """ - - _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) - self.recommendations = None - self.code = None - self.message = None - - -class KubernetesClusterInfo(msrest.serialization.Model): - """Kubernetes cluster configuration. - - 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 etcd_info: Etcd configuration. - :vartype etcd_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EtcdInfo - :ivar nodes: Kubernetes cluster nodes. - :vartype nodes: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.NodeInfo] - :param version: Required. Kubernetes cluster version. - :type version: str - """ - - _validation = { - 'etcd_info': {'readonly': True}, - 'nodes': {'readonly': True}, - 'version': {'required': True}, - } - - _attribute_map = { - 'etcd_info': {'key': 'etcdInfo', 'type': 'EtcdInfo'}, - 'nodes': {'key': 'nodes', 'type': '[NodeInfo]'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesClusterInfo, self).__init__(**kwargs) - self.etcd_info = None - self.nodes = None - self.version = kwargs['version'] - - -class KubernetesIPConfiguration(msrest.serialization.Model): - """Kubernetes node IP configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar port: Port of the Kubernetes node. - :vartype port: str - :param ip_address: IP address of the Kubernetes node. - :type ip_address: str - """ - - _validation = { - 'port': {'readonly': True}, - } - - _attribute_map = { - 'port': {'key': 'port', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesIPConfiguration, self).__init__(**kwargs) - self.port = None - self.ip_address = kwargs.get('ip_address', None) - - -class KubernetesRole(Role): - """Kubernetes role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param host_platform: Host OS supported by the Kubernetes role. Possible values include: - "Windows", "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType - :ivar provisioning_state: State of Kubernetes deployment. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". - :vartype provisioning_state: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesState - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". - :vartype host_platform_type: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.HostPlatformType - :param kubernetes_cluster_info: Kubernetes cluster configuration. - :type kubernetes_cluster_info: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesClusterInfo - :param kubernetes_role_resources: Kubernetes role resources. - :type kubernetes_role_resources: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleResources - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'kubernetes_cluster_info': {'key': 'properties.kubernetesClusterInfo', 'type': 'KubernetesClusterInfo'}, - 'kubernetes_role_resources': {'key': 'properties.kubernetesRoleResources', 'type': 'KubernetesRoleResources'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRole, self).__init__(**kwargs) - self.kind = 'Kubernetes' # type: str - self.host_platform = kwargs.get('host_platform', None) - self.provisioning_state = None - self.host_platform_type = None - self.kubernetes_cluster_info = kwargs.get('kubernetes_cluster_info', None) - self.kubernetes_role_resources = kwargs.get('kubernetes_role_resources', None) - self.role_status = kwargs.get('role_status', None) - - -class KubernetesRoleCompute(msrest.serialization.Model): - """Kubernetes role compute resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param vm_profile: Required. VM profile. - :type vm_profile: str - :ivar memory_in_bytes: Memory in bytes. - :vartype memory_in_bytes: long - :ivar processor_count: Processor count. - :vartype processor_count: int - """ - - _validation = { - 'vm_profile': {'required': True}, - 'memory_in_bytes': {'readonly': True}, - 'processor_count': {'readonly': True}, - } - - _attribute_map = { - 'vm_profile': {'key': 'vmProfile', 'type': 'str'}, - 'memory_in_bytes': {'key': 'memoryInBytes', 'type': 'long'}, - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleCompute, self).__init__(**kwargs) - self.vm_profile = kwargs['vm_profile'] - self.memory_in_bytes = None - self.processor_count = None - - -class KubernetesRoleNetwork(msrest.serialization.Model): - """Kubernetes role network resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar cni_config: Cni configuration. - :vartype cni_config: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.CniConfig - :ivar load_balancer_config: Load balancer configuration. - :vartype load_balancer_config: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.LoadBalancerConfig - """ - - _validation = { - 'cni_config': {'readonly': True}, - 'load_balancer_config': {'readonly': True}, - } - - _attribute_map = { - 'cni_config': {'key': 'cniConfig', 'type': 'CniConfig'}, - 'load_balancer_config': {'key': 'loadBalancerConfig', 'type': 'LoadBalancerConfig'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleNetwork, self).__init__(**kwargs) - self.cni_config = None - self.load_balancer_config = None - - -class KubernetesRoleResources(msrest.serialization.Model): - """Kubernetes role resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param storage: Kubernetes role storage resource. - :type storage: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleStorage - :param compute: Required. Kubernetes role compute resource. - :type compute: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleCompute - :ivar network: Kubernetes role network resource. - :vartype network: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleNetwork - """ - - _validation = { - 'compute': {'required': True}, - 'network': {'readonly': True}, - } - - _attribute_map = { - 'storage': {'key': 'storage', 'type': 'KubernetesRoleStorage'}, - 'compute': {'key': 'compute', 'type': 'KubernetesRoleCompute'}, - 'network': {'key': 'network', 'type': 'KubernetesRoleNetwork'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleResources, self).__init__(**kwargs) - self.storage = kwargs.get('storage', None) - self.compute = kwargs['compute'] - self.network = None - - -class KubernetesRoleStorage(msrest.serialization.Model): - """Kubernetes role storage resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar storage_classes: Kubernetes storage class info. - :vartype storage_classes: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleStorageClassInfo] - :param endpoints: Mount points of shares in role(s). - :type endpoints: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] - """ - - _validation = { - 'storage_classes': {'readonly': True}, - } - - _attribute_map = { - 'storage_classes': {'key': 'storageClasses', 'type': '[KubernetesRoleStorageClassInfo]'}, - 'endpoints': {'key': 'endpoints', 'type': '[MountPointMap]'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorage, self).__init__(**kwargs) - self.storage_classes = None - self.endpoints = kwargs.get('endpoints', None) - - -class KubernetesRoleStorageClassInfo(msrest.serialization.Model): - """Kubernetes storage class info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Storage class name. - :vartype name: str - :ivar type: Storage class type. - :vartype type: str - :ivar posix_compliant: If provisioned storage is posix compliant. Possible values include: - "Invalid", "Enabled", "Disabled". - :vartype posix_compliant: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PosixComplianceStatus - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'posix_compliant': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'posix_compliant': {'key': 'posixCompliant', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorageClassInfo, self).__init__(**kwargs) - self.name = None - self.type = None - self.posix_compliant = None - - -class LoadBalancerConfig(msrest.serialization.Model): - """Load balancer configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: Load balancer type. - :vartype type: str - :ivar version: Load balancer version. - :vartype version: str - """ - - _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LoadBalancerConfig, self).__init__(**kwargs) - self.type = None - self.version = None - - -class MECRole(Role): - """MEC role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes - :ivar system_data: Role configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param connection_string: Activation key of the MEC. - :type connection_string: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - :param controller_endpoint: Controller Endpoint. - :type controller_endpoint: str - :param resource_unique_id: Unique Id of the Resource. - :type resource_unique_id: str - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'AsymmetricEncryptedSecret'}, - 'controller_endpoint': {'key': 'properties.controllerEndpoint', 'type': 'str'}, - 'resource_unique_id': {'key': 'properties.resourceUniqueId', 'type': 'str'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MECRole, self).__init__(**kwargs) - self.kind = 'MEC' # type: str - self.connection_string = kwargs.get('connection_string', None) - self.controller_endpoint = kwargs.get('controller_endpoint', None) - self.resource_unique_id = kwargs.get('resource_unique_id', None) - self.role_status = kwargs.get('role_status', None) - - -class MetricConfiguration(msrest.serialization.Model): - """Metric configuration. - - All required parameters must be populated in order to send to Azure. - - :param resource_id: Required. The Resource ID on which the metrics should be pushed. - :type resource_id: str - :param mdm_account: The MDM account to which the counters should be pushed. - :type mdm_account: str - :param metric_name_space: The MDM namespace to which the counters should be pushed. This is - required if MDMAccount is specified. - :type metric_name_space: str - :param counter_sets: Required. Host name for the IoT hub associated to the device. - :type counter_sets: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCounterSet] - """ - - _validation = { - 'resource_id': {'required': True}, - 'counter_sets': {'required': True}, - } - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'mdm_account': {'key': 'mdmAccount', 'type': 'str'}, - 'metric_name_space': {'key': 'metricNameSpace', 'type': 'str'}, - 'counter_sets': {'key': 'counterSets', 'type': '[MetricCounterSet]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricConfiguration, self).__init__(**kwargs) - self.resource_id = kwargs['resource_id'] - self.mdm_account = kwargs.get('mdm_account', None) - self.metric_name_space = kwargs.get('metric_name_space', None) - self.counter_sets = kwargs['counter_sets'] - - -class MetricCounter(msrest.serialization.Model): - """The metric counter. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The counter name. - :type name: str - :param instance: The instance from which counter should be collected. - :type instance: str - :param dimension_filter: The dimension filter. - :type dimension_filter: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimension] - :param additional_dimensions: The additional dimensions to be added to metric. - :type additional_dimensions: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimension] - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, - 'dimension_filter': {'key': 'dimensionFilter', 'type': '[MetricDimension]'}, - 'additional_dimensions': {'key': 'additionalDimensions', 'type': '[MetricDimension]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCounter, self).__init__(**kwargs) - self.name = kwargs['name'] - self.instance = kwargs.get('instance', None) - self.dimension_filter = kwargs.get('dimension_filter', None) - self.additional_dimensions = kwargs.get('additional_dimensions', None) - - -class MetricCounterSet(msrest.serialization.Model): - """The metric counter set. - - All required parameters must be populated in order to send to Azure. - - :param counters: Required. The counters that should be collected in this set. - :type counters: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCounter] - """ - - _validation = { - 'counters': {'required': True}, - } - - _attribute_map = { - 'counters': {'key': 'counters', 'type': '[MetricCounter]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCounterSet, self).__init__(**kwargs) - self.counters = kwargs['counters'] - - -class MetricDimension(msrest.serialization.Model): - """The metric dimension. - - All required parameters must be populated in order to send to Azure. - - :param source_type: Required. The dimension type. - :type source_type: str - :param source_name: Required. The dimension value. - :type source_name: str - """ - - _validation = { - 'source_type': {'required': True}, - 'source_name': {'required': True}, - } - - _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'source_name': {'key': 'sourceName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) - self.source_type = kwargs['source_type'] - self.source_name = kwargs['source_name'] - - -class MetricDimensionV1(msrest.serialization.Model): - """Metric Dimension v1. - - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimensionV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecificationV1(msrest.serialization.Model): - """Metric specification version 1. - - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricAggregationType] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecificationV1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.dimensions = kwargs.get('dimensions', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - - -class MonitoringMetricConfiguration(ARMBaseModel): - """The metric setting details for the role. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: MonitoringConfiguration on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param metric_configurations: Required. The metrics configuration details. - :type metric_configurations: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricConfiguration] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'metric_configurations': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'metric_configurations': {'key': 'properties.metricConfigurations', 'type': '[MetricConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfiguration, self).__init__(**kwargs) - self.system_data = None - self.metric_configurations = kwargs['metric_configurations'] - - -class MonitoringMetricConfigurationList(msrest.serialization.Model): - """Collection of metric configurations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of metric configurations. - :vartype value: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MonitoringMetricConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfigurationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class MountPointMap(msrest.serialization.Model): - """The share mount point. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str - :ivar role_id: ID of the role to which share is mounted. - :vartype role_id: str - :ivar mount_point: Mount point for the share. - :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". - :vartype mount_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive", - "MEC", "CloudEdgeManagement", "Kubernetes". - :vartype role_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes - """ - - _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.role_id = None - self.mount_point = None - self.mount_type = None - self.role_type = None - - -class NetworkAdapter(msrest.serialization.Model): - """Represents the networkAdapter on a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar adapter_id: Instance ID of network adapter. - :vartype adapter_id: str - :ivar adapter_position: Hardware position of network adapter. - :vartype adapter_position: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapterPosition - :ivar index: Logical index of the adapter. - :vartype index: int - :ivar node_id: Node ID of the network adapter. - :vartype node_id: str - :ivar network_adapter_name: Network adapter name. - :vartype network_adapter_name: str - :ivar label: Hardware label for the adapter. - :vartype label: str - :ivar mac_address: MAC address. - :vartype mac_address: str - :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". - :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapterDHCPStatus - :ivar ipv4_configuration: The IPv4 configuration of the network adapter. - :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Ipv4Config - :ivar ipv6_configuration: The IPv6 configuration of the network adapter. - :vartype ipv6_configuration: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Ipv6Config - :ivar ipv6_link_local_address: The IPv6 local address. - :vartype ipv6_link_local_address: str - :ivar dns_servers: The list of DNS Servers of the device. - :vartype dns_servers: list[str] - """ - - _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, - } - - _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapter, self).__init__(**kwargs) - self.adapter_id = None - self.adapter_position = None - self.index = None - self.node_id = None - self.network_adapter_name = None - self.label = None - self.mac_address = None - self.link_speed = None - self.status = None - self.rdma_status = kwargs.get('rdma_status', None) - self.dhcp_status = kwargs.get('dhcp_status', None) - self.ipv4_configuration = None - self.ipv6_configuration = None - self.ipv6_link_local_address = None - self.dns_servers = None - - -class NetworkAdapterPosition(msrest.serialization.Model): - """The network adapter position. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". - :vartype network_group: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkGroup - :ivar port: The port. - :vartype port: int - """ - - _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, - } - - _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) - self.network_group = None - self.port = None - - -class NetworkSettings(ARMBaseModel): - """The network settings of a device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: NetworkSettings on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :ivar network_adapters: The network adapter list on the device. - :vartype network_adapters: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapter] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'network_adapters': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) - self.system_data = None - self.network_adapters = None - - -class Node(ARMBaseModel): - """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) - self.node_status = None - self.node_chassis_serial_number = None - self.node_serial_number = None - self.node_display_name = None - self.node_friendly_software_version = None - self.node_hcs_version = None - self.node_instance_id = None - - -class NodeInfo(msrest.serialization.Model): - """Kubernetes node info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Node name. - :vartype name: str - :ivar type: Node type - Master/Worker. Possible values include: "Invalid", "Master", "Worker". - :vartype type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesNodeType - :param ip_configuration: IP Configuration of the Kubernetes node. - :type ip_configuration: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesIPConfiguration] - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_configuration': {'key': 'ipConfiguration', 'type': '[KubernetesIPConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeInfo, self).__init__(**kwargs) - self.name = None - self.type = None - self.ip_configuration = kwargs.get('ip_configuration', None) - - -class NodeList(msrest.serialization.Model): - """Collection of Nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of Nodes. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Node] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) - self.value = None - self.next_link = kwargs.get('next_link', None) - - -class Operation(msrest.serialization.Model): - """Operations. - - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param service_specification: Service specification. - :type service_specification: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ServiceSpecification - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.service_specification = kwargs.get('service_specification', None) - - -class OperationDisplay(msrest.serialization.Model): - """Operation display properties. - - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str - """ - - _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 = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """The list of operations used for the discovery of available provider operations. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class Order(ARMBaseModel): - """The order details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Order configured on ASE resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Address - :ivar current_status: Current status of the order. - :vartype current_status: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OrderStatus - :ivar order_history: List of status changes in the order. - :vartype order_history: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.OrderStatus] - :ivar serial_number: Serial number of the device. - :vartype serial_number: str - :ivar delivery_tracking_info: Tracking information for the package delivered to the customer - whether it has an original or a replacement device. - :vartype delivery_tracking_info: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.TrackingInfo] - :ivar return_tracking_info: Tracking information for the package returned from the customer - whether it has an original or a replacement device. - :vartype return_tracking_info: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.TrackingInfo] - :param shipment_type: ShipmentType of the order. Possible values include: "NotApplicable", - "ShippedToCustomer", "SelfPickup". - :type shipment_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShipmentType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'current_status': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - 'shipment_type': {'key': 'properties.shipmentType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Order, self).__init__(**kwargs) - self.system_data = None - self.contact_information = kwargs.get('contact_information', None) - self.shipping_address = kwargs.get('shipping_address', None) - self.current_status = None - self.order_history = None - self.serial_number = None - self.delivery_tracking_info = None - self.return_tracking_info = None - self.shipment_type = kwargs.get('shipment_type', None) - - -class OrderList(msrest.serialization.Model): - """List of order entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of orders. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OrderStatus(msrest.serialization.Model): - """Represents a single status change. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfillment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", - "AwaitingPickup", "PickupCompleted", "AwaitingDrop". - :type status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OrderState - :ivar update_date_time: Time of status update. - :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str - :ivar tracking_information: Tracking information related to the state in the ordering flow. - :vartype tracking_information: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TrackingInfo - :ivar additional_order_details: Dictionary to hold generic information which is not stored - by the already existing properties. - :vartype additional_order_details: dict[str, str] - """ - - _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'tracking_information': {'readonly': True}, - 'additional_order_details': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'tracking_information': {'key': 'trackingInformation', 'type': 'TrackingInfo'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) - self.status = kwargs['status'] - self.update_date_time = None - self.comments = kwargs.get('comments', None) - self.tracking_information = None - self.additional_order_details = None - - -class PeriodicTimerEventTrigger(Trigger): - """Trigger details. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Trigger in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against - its usage. For example, if a periodic timer trigger is intended for certain specific IoT - modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str - self.source_info = kwargs['source_info'] - self.sink_info = kwargs['sink_info'] - self.custom_context_tag = kwargs.get('custom_context_tag', None) - - -class PeriodicTimerSourceInfo(msrest.serialization.Model): - """Periodic timer event source. - - All required parameters must be populated in order to send to Azure. - - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str - """ - - _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) - self.start_time = kwargs['start_time'] - self.schedule = kwargs['schedule'] - self.topic = kwargs.get('topic', None) - - -class RefreshDetails(msrest.serialization.Model): - """Fields for tracking refresh job on the share or container. - - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or - container, this field indicates the ARM resource ID of that job. The field is empty if no job - is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh - job on this particular share or container, if any. This could be a failed job or a successful - job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or - container,if any. This could be a failed job or a successful job. - :type last_job: str - """ - - _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RefreshDetails, self).__init__(**kwargs) - self.in_progress_refresh_job_id = kwargs.get('in_progress_refresh_job_id', None) - self.last_completed_refresh_job_time_in_utc = kwargs.get('last_completed_refresh_job_time_in_utc', None) - self.error_manifest_file = kwargs.get('error_manifest_file', None) - self.last_job = kwargs.get('last_job', None) - - -class ResourceIdentity(msrest.serialization.Model): - """Msi identity details of the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param type: Identity type. Possible values include: "None", "SystemAssigned", "UserAssigned". - :type type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MsiIdentityType - :ivar principal_id: Service Principal Id backing the Msi. - :vartype principal_id: str - :ivar tenant_id: Home Tenant Id. - :vartype tenant_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.principal_id = None - self.tenant_id = None - - -class ResourceMoveDetails(msrest.serialization.Model): - """Fields for tracking resource move. - - :param operation_in_progress: Denotes whether move operation is in progress. Possible values - include: "None", "ResourceMoveInProgress", "ResourceMoveFailed". - :type operation_in_progress: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceMoveStatus - :param operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to - finish. - :type operation_in_progress_lock_timeout_in_utc: ~datetime.datetime - """ - - _attribute_map = { - 'operation_in_progress': {'key': 'operationInProgress', 'type': 'str'}, - 'operation_in_progress_lock_timeout_in_utc': {'key': 'operationInProgressLockTimeoutInUTC', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceMoveDetails, self).__init__(**kwargs) - self.operation_in_progress = kwargs.get('operation_in_progress', None) - self.operation_in_progress_lock_timeout_in_utc = kwargs.get('operation_in_progress_lock_timeout_in_utc', None) - - -class ResourceTypeSku(msrest.serialization.Model): - """Resource type Sku object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: The resource type. - :vartype resource_type: str - :ivar skus: The skus. - :vartype skus: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuInformation] - """ - - _validation = { - 'resource_type': {'readonly': True}, - 'skus': {'readonly': True}, - } - - _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'skus': {'key': 'skus', 'type': '[SkuInformation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) - self.resource_type = None - self.skus = None - - -class RoleList(msrest.serialization.Model): - """Collection of all the roles on the Data Box Edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The Value. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RoleSinkInfo(msrest.serialization.Model): - """Compute role against which events will be raised. - - All required parameters must be populated in order to send to Azure. - - :param role_id: Required. Compute role ID. - :type role_id: str - """ - - _validation = { - 'role_id': {'required': True}, - } - - _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) - self.role_id = kwargs['role_id'] - - -class Secret(msrest.serialization.Model): - """Holds device secret either as a KeyVault reference or as an encrypted value. - - :param encrypted_secret: Encrypted (using device public key) secret value. - :type encrypted_secret: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - :param key_vault_id: Id of the Key-Vault where secret is stored (ex: - secrets/AuthClientSecret/82ef4346187a4033a10d629cde07d740). - :type key_vault_id: str - """ - - _attribute_map = { - 'encrypted_secret': {'key': 'encryptedSecret', 'type': 'AsymmetricEncryptedSecret'}, - 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Secret, self).__init__(**kwargs) - self.encrypted_secret = kwargs.get('encrypted_secret', None) - self.key_vault_id = kwargs.get('key_vault_id', None) - - -class SecuritySettings(ARMBaseModel): - """The security settings of a device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) - self.device_admin_password = kwargs['device_admin_password'] - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification. - - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricSpecificationV1] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Share(ARMBaseModel): - """Represents a share on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: Share on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share - (required for SMB protocol). - :type user_access_rights: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the - share(required for NFS protocol). - :type client_access_rights: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RefreshDetails - :ivar share_mappings: Share mount point to the role. - :vartype share_mappings: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Share, self).__init__(**kwargs) - self.system_data = None - self.description = kwargs.get('description', None) - self.share_status = kwargs['share_status'] - self.monitoring_status = kwargs['monitoring_status'] - self.azure_container_info = kwargs.get('azure_container_info', None) - self.access_protocol = kwargs['access_protocol'] - self.user_access_rights = kwargs.get('user_access_rights', None) - self.client_access_rights = kwargs.get('client_access_rights', None) - self.refresh_details = kwargs.get('refresh_details', None) - self.share_mappings = None - self.data_policy = kwargs.get('data_policy', None) - - -class ShareAccessRight(msrest.serialization.Model): - """Specifies the mapping between this particular user and the type of access he has on shares on this device. - - All required parameters must be populated in order to send to Azure. - - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessType - """ - - _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) - self.share_id = kwargs['share_id'] - self.access_type = kwargs['access_type'] - - -class ShareList(msrest.serialization.Model): - """Collection of all the shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of shares. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Sku(msrest.serialization.Model): - """The SKU type. - - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", - "EP2_256_2T4_W", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC", "Management". - :type name: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuTier - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = kwargs.get('tier', None) - - -class SkuCost(msrest.serialization.Model): - """The metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The cost quantity. - :vartype quantity: long - :ivar extended_unit: The extended unit. - :vartype extended_unit: str - """ - - _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, - } - - _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) - self.meter_id = None - self.quantity = None - self.extended_unit = None - - -class SkuInformation(msrest.serialization.Model): - """Sku information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The sku name. - :vartype name: str - :ivar tier: The sku tier. - :vartype tier: str - :ivar kind: The sku kind. - :vartype kind: str - :ivar family: The Sku family. - :vartype family: str - :ivar costs: The pricing info of the Sku. - :vartype costs: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuCost] - :ivar locations: The locations where Sku is available. - :vartype locations: list[str] - :ivar location_info: The locations where Sku is available with zones and sites info. - :vartype location_info: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuLocationInfo] - :ivar required_quota_ids: The required quotaIds for the sku to be available. - :vartype required_quota_ids: list[str] - :ivar required_features: The required features for the sku to be available. - :vartype required_features: list[str] - """ - - _validation = { - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'family': {'readonly': True}, - 'costs': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) - self.name = None - self.tier = None - self.kind = None - self.family = None - self.costs = None - self.locations = None - self.location_info = None - self.required_quota_ids = None - self.required_features = None - - -class SkuInformationList(msrest.serialization.Model): - """List of SKU Information objects. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ResourceTypeSku objects. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceTypeSku] - :ivar next_link: Links to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SkuLocationInfo(msrest.serialization.Model): - """The location info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The location. - :vartype location: str - :ivar zones: The zones. - :vartype zones: list[str] - :ivar sites: The sites. - :vartype sites: list[str] - """ - - _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) - self.location = None - self.zones = None - self.sites = None - - -class StorageAccount(ARMBaseModel): - """Represents a Storage Account on the Data Box Edge/Gateway device. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: StorageAccount object on ASE device. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountStatus - :param data_policy: Required. Data policy of the storage Account. Possible values include: - "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str - :ivar blob_endpoint: BlobEndpoint of Storage Account. - :vartype blob_endpoint: str - :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy - set to Cloud. - :vartype container_count: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'data_policy': {'required': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccount, self).__init__(**kwargs) - self.system_data = None - self.description = kwargs.get('description', None) - self.storage_account_status = kwargs.get('storage_account_status', None) - self.data_policy = kwargs['data_policy'] - self.storage_account_credential_id = kwargs.get('storage_account_credential_id', None) - self.blob_endpoint = None - self.container_count = None - - -class StorageAccountCredential(ARMBaseModel): - """The storage account credential. - - 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: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: StorageAccountCredential object. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredential, self).__init__(**kwargs) - self.system_data = None - self.alias = kwargs['alias'] - self.user_name = kwargs.get('user_name', None) - self.account_key = kwargs.get('account_key', None) - self.connection_string = kwargs.get('connection_string', None) - self.ssl_status = kwargs['ssl_status'] - self.blob_domain_name = kwargs.get('blob_domain_name', None) - self.account_type = kwargs['account_type'] - self.storage_account_id = kwargs.get('storage_account_id', None) - - -class StorageAccountCredentialList(msrest.serialization.Model): - """The collection of storage account credentials. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The value. - :vartype value: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class StorageAccountList(msrest.serialization.Model): - """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of storageAccounts. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SubscriptionRegisteredFeatures(msrest.serialization.Model): - """SubscriptionRegisteredFeatures. - - :param name: - :type name: str - :param state: - :type state: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionRegisteredFeatures, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.state = kwargs.get('state', None) - - -class SymmetricKey(msrest.serialization.Model): - """Symmetric key for authentication. - - :param connection_string: Connection string based on the symmetric key. - :type connection_string: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - """ - - _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) - self.connection_string = kwargs.get('connection_string', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type 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, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TrackingInfo(msrest.serialization.Model): - """Tracking courier information. - - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str - """ - - _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackingInfo, self).__init__(**kwargs) - self.serial_number = kwargs.get('serial_number', None) - self.carrier_name = kwargs.get('carrier_name', None) - self.tracking_id = kwargs.get('tracking_id', None) - self.tracking_url = kwargs.get('tracking_url', None) - - -class TriggerList(msrest.serialization.Model): - """Collection of all trigger on the data box edge device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of triggers. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class UpdateDetails(msrest.serialization.Model): - """Update Specific attributes. - - :param update_title: Title of the Update. - :type update_title: str - :param update_size: Size of the update(In Bytes). - :type update_size: float - :param update_type: Type of the Update. Possible values include: "Software", "Kubernetes", - "Firmware". - :type update_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateType - :param target_version: Target Version number. - :type target_version: str - :param estimated_install_time_in_mins: Estimated Install Time for the update. - :type estimated_install_time_in_mins: int - :param reboot_behavior: Indicates if updates are available and at least one of the updates - needs a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :type reboot_behavior: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.InstallRebootBehavior - :param status: Status of the update. Possible values include: "DownloadPending", - "DownloadStarted", "DownloadCompleted", "InstallStarted", "InstallCompleted". - :type status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateStatus - """ - - _attribute_map = { - 'update_title': {'key': 'updateTitle', 'type': 'str'}, - 'update_size': {'key': 'updateSize', 'type': 'float'}, - 'update_type': {'key': 'updateType', 'type': 'str'}, - 'target_version': {'key': 'targetVersion', 'type': 'str'}, - 'estimated_install_time_in_mins': {'key': 'estimatedInstallTimeInMins', 'type': 'int'}, - 'reboot_behavior': {'key': 'rebootBehavior', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateDetails, self).__init__(**kwargs) - self.update_title = kwargs.get('update_title', None) - self.update_size = kwargs.get('update_size', None) - self.update_type = kwargs.get('update_type', None) - self.target_version = kwargs.get('target_version', None) - self.estimated_install_time_in_mins = kwargs.get('estimated_install_time_in_mins', None) - self.reboot_behavior = kwargs.get('reboot_behavior', None) - self.status = kwargs.get('status', None) - - -class UpdateDownloadProgress(msrest.serialization.Model): - """Details about the download progress of update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". - :vartype download_phase: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DownloadPhase - :ivar percent_complete: Percentage of completion. - :vartype percent_complete: int - :ivar total_bytes_to_download: Total bytes to download. - :vartype total_bytes_to_download: float - :ivar total_bytes_downloaded: Total bytes downloaded. - :vartype total_bytes_downloaded: float - :ivar number_of_updates_to_download: Number of updates to download. - :vartype number_of_updates_to_download: int - :ivar number_of_updates_downloaded: Number of updates downloaded. - :vartype number_of_updates_downloaded: int - """ - - _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, - } - - _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) - self.download_phase = None - self.percent_complete = None - self.total_bytes_to_download = None - self.total_bytes_downloaded = None - self.number_of_updates_to_download = None - self.number_of_updates_downloaded = None - - -class UpdateInstallProgress(msrest.serialization.Model): - """Progress details during installation of updates. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar percent_complete: Percentage completed. - :vartype percent_complete: int - :ivar number_of_updates_to_install: Number of updates to install. - :vartype number_of_updates_to_install: int - :ivar number_of_updates_installed: Number of updates installed. - :vartype number_of_updates_installed: int - """ - - _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, - } - - _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) - self.percent_complete = None - self.number_of_updates_to_install = None - self.number_of_updates_installed = None - - -class UpdateSummary(ARMBaseModel): - """Details about ongoing updates and availability of updates on the device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: UpdateSummary Result. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed - (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime - :ivar last_completed_download_job_date_time: The time when the last Download job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_download_job_date_time: ~datetime.datetime - :ivar last_completed_download_job_id: JobId of the last ran download job.(Can be - success/cancelled/failed). - :vartype last_completed_download_job_id: str - :ivar last_download_job_status: JobStatus of the last ran download job. Possible values - include: "Invalid", "Running", "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype last_download_job_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobStatus - :ivar last_completed_install_job_date_time: The time when the last Install job was completed - (success/cancelled/failed) on the appliance. - :vartype last_completed_install_job_date_time: ~datetime.datetime - :ivar last_completed_install_job_id: JobId of the last ran install job.(Can be - success/cancelled/failed). - :vartype last_completed_install_job_id: str - :ivar last_install_job_status: JobStatus of the last ran install job. Possible values include: - "Invalid", "Running", "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". - :vartype last_install_job_status: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobStatus - :ivar total_number_of_updates_available: The number of updates available for the current device - version as per the last device scan. - :vartype total_number_of_updates_available: int - :ivar total_number_of_updates_pending_download: The total number of items pending download. - :vartype total_number_of_updates_pending_download: int - :ivar total_number_of_updates_pending_install: The total number of items pending install. - :vartype total_number_of_updates_pending_install: int - :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :vartype reboot_behavior: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". - :vartype ongoing_update_operation: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateOperation - :ivar in_progress_download_job_id: The job ID of the download job in progress. - :vartype in_progress_download_job_id: str - :ivar in_progress_install_job_id: The job ID of the install job in progress. - :vartype in_progress_install_job_id: str - :ivar in_progress_download_job_started_date_time: The time when the currently running download - (if any) started. - :vartype in_progress_download_job_started_date_time: ~datetime.datetime - :ivar in_progress_install_job_started_date_time: The time when the currently running install - (if any) started. - :vartype in_progress_install_job_started_date_time: ~datetime.datetime - :ivar update_titles: The list of updates available for install. - :vartype update_titles: list[str] - :ivar updates: The list of updates available for install. - :vartype updates: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateDetails] - :ivar total_update_size_in_bytes: The total size of updates available for download in bytes. - :vartype total_update_size_in_bytes: float - :ivar total_time_in_minutes: The total time in Minutes. - :vartype total_time_in_minutes: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_download_job_id': {'readonly': True}, - 'last_download_job_status': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'last_completed_install_job_id': {'readonly': True}, - 'last_install_job_status': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'updates': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - 'total_time_in_minutes': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_id': {'key': 'properties.lastCompletedDownloadJobId', 'type': 'str'}, - 'last_download_job_status': {'key': 'properties.lastDownloadJobStatus', 'type': 'str'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_id': {'key': 'properties.lastCompletedInstallJobId', 'type': 'str'}, - 'last_install_job_status': {'key': 'properties.lastInstallJobStatus', 'type': 'str'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'updates': {'key': 'properties.updates', 'type': '[UpdateDetails]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, - 'total_time_in_minutes': {'key': 'properties.totalTimeInMinutes', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateSummary, self).__init__(**kwargs) - self.system_data = None - self.device_version_number = kwargs.get('device_version_number', None) - self.friendly_device_version_name = kwargs.get('friendly_device_version_name', None) - self.device_last_scanned_date_time = kwargs.get('device_last_scanned_date_time', None) - self.last_completed_scan_job_date_time = kwargs.get('last_completed_scan_job_date_time', None) - self.last_completed_download_job_date_time = None - self.last_completed_download_job_id = None - self.last_download_job_status = None - self.last_completed_install_job_date_time = None - self.last_completed_install_job_id = None - self.last_install_job_status = None - self.total_number_of_updates_available = None - self.total_number_of_updates_pending_download = None - self.total_number_of_updates_pending_install = None - self.reboot_behavior = None - self.ongoing_update_operation = None - self.in_progress_download_job_id = None - self.in_progress_install_job_id = None - self.in_progress_download_job_started_date_time = None - self.in_progress_install_job_started_date_time = None - self.update_titles = None - self.updates = None - self.total_update_size_in_bytes = None - self.total_time_in_minutes = None - - -class UploadCertificateRequest(msrest.serialization.Model): - """The upload certificate request. - - All required parameters must be populated in order to send to Azure. - - :param authentication_type: The authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type authentication_type: str or - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str - """ - - _validation = { - 'certificate': {'required': True}, - } - - _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateRequest, self).__init__(**kwargs) - self.authentication_type = kwargs.get('authentication_type', None) - self.certificate = kwargs['certificate'] - - -class UploadCertificateResponse(msrest.serialization.Model): - """The upload registration certificate response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param auth_type: Specifies authentication type. Possible values include: "Invalid", - "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AuthenticationType - :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. - :vartype resource_id: str - :ivar aad_authority: Azure Active Directory tenant authority. - :vartype aad_authority: str - :ivar aad_tenant_id: Azure Active Directory tenant ID. - :vartype aad_tenant_id: str - :ivar service_principal_client_id: Azure Active Directory service principal client ID. - :vartype service_principal_client_id: str - :ivar service_principal_object_id: Azure Active Directory service principal object ID. - :vartype service_principal_object_id: str - :ivar azure_management_endpoint_audience: The azure management endpoint audience. - :vartype azure_management_endpoint_audience: str - :ivar aad_audience: Identifier of the target resource that is the recipient of the requested - token. - :vartype aad_audience: str - """ - - _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, - } - - _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) - self.auth_type = kwargs.get('auth_type', None) - self.resource_id = None - self.aad_authority = None - self.aad_tenant_id = None - self.service_principal_client_id = None - self.service_principal_object_id = None - self.azure_management_endpoint_audience = None - self.aad_audience = None - - -class User(ARMBaseModel): - """Represents a user who has access to one or more shares on the Data Box Edge/Gateway device. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar system_data: User in DataBoxEdge Resource. - :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param encrypted_password: The password details. - :type encrypted_password: - ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - :ivar share_access_rights: List of shares that the user has rights on. This field should not be - specified during user creation. - :vartype share_access_rights: - list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessRight] - :param user_type: Type of the user. Possible values include: "Share", "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UserType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_access_rights': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(User, self).__init__(**kwargs) - self.system_data = None - self.encrypted_password = kwargs.get('encrypted_password', None) - self.share_access_rights = None - self.user_type = kwargs.get('user_type', None) - - -class UserAccessRight(msrest.serialization.Model): - """The mapping between a particular user and the access type on the SMB share. - - All required parameters must be populated in order to send to Azure. - - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessType - """ - - _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, - } - - _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) - self.user_id = kwargs['user_id'] - self.access_type = kwargs['access_type'] - - -class UserList(msrest.serialization.Model): - """Collection of users. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of users. - :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] - :ivar next_link: Link to the next set of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) - self.value = None - self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_models_py3.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_models_py3.py index 646fd8f45498..a9a82f4b2376 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_models_py3.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,14 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization -from ._data_box_edge_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class ARMBaseModel(msrest.serialization.Model): +class ARMBaseModel(_serialization.Model): """Represents the base class for all object models. Variables are only populated by the server, and will be ignored when sending a request. @@ -28,22 +31,20 @@ class ARMBaseModel(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ARMBaseModel, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -52,8 +53,8 @@ def __init__( class Addon(ARMBaseModel): """Role Addon. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ArcAddon, IoTAddon. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ArcAddon, IoTAddon Variables are only populated by the server, and will be ignored when sending a request. @@ -65,43 +66,38 @@ class Addon(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - _subtype_map = { - 'kind': {'ArcForKubernetes': 'ArcAddon', 'IotEdge': 'IoTAddon'} - } + _subtype_map = {"kind": {"ArcForKubernetes": "ArcAddon", "IotEdge": "IoTAddon"}} - def __init__( - self, - **kwargs - ): - super(Addon, self).__init__(**kwargs) - self.kind = 'Addon' # type: str + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None self.system_data = None -class AddonList(msrest.serialization.Model): +class AddonList(_serialization.Model): """Collection of all the Role addon on the Azure Stack Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -113,57 +109,55 @@ class AddonList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Addon]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Address(msrest.serialization.Model): +class Address(_serialization.Model): """The shipping address of the customer. All required parameters must be populated in order to send to Azure. - :param address_line1: The address line1. - :type address_line1: str - :param address_line2: The address line2. - :type address_line2: str - :param address_line3: The address line3. - :type address_line3: str - :param postal_code: The postal code. - :type postal_code: str - :param city: The city name. - :type city: str - :param state: The state name. - :type state: str - :param country: Required. The country name. - :type country: str + :ivar address_line1: The address line1. + :vartype address_line1: str + :ivar address_line2: The address line2. + :vartype address_line2: str + :ivar address_line3: The address line3. + :vartype address_line3: str + :ivar postal_code: The postal code. + :vartype postal_code: str + :ivar city: The city name. + :vartype city: str + :ivar state: The state name. + :vartype state: str + :ivar country: The country name. Required. + :vartype country: str """ _validation = { - 'country': {'required': True}, + "country": {"required": True}, } _attribute_map = { - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, + "address_line1": {"key": "addressLine1", "type": "str"}, + "address_line2": {"key": "addressLine2", "type": "str"}, + "address_line3": {"key": "addressLine3", "type": "str"}, + "postal_code": {"key": "postalCode", "type": "str"}, + "city": {"key": "city", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "country": {"key": "country", "type": "str"}, } def __init__( @@ -178,7 +172,23 @@ def __init__( state: Optional[str] = None, **kwargs ): - super(Address, self).__init__(**kwargs) + """ + :keyword address_line1: The address line1. + :paramtype address_line1: str + :keyword address_line2: The address line2. + :paramtype address_line2: str + :keyword address_line3: The address line3. + :paramtype address_line3: str + :keyword postal_code: The postal code. + :paramtype postal_code: str + :keyword city: The city name. + :paramtype city: str + :keyword state: The state name. + :paramtype state: str + :keyword country: The country name. Required. + :paramtype country: str + """ + super().__init__(**kwargs) self.address_line1 = address_line1 self.address_line2 = address_line2 self.address_line3 = address_line3 @@ -188,7 +198,7 @@ def __init__( self.country = country -class Alert(ARMBaseModel): +class Alert(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Alert on the data box edge/gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -209,7 +219,7 @@ class Alert(ARMBaseModel): :vartype appeared_at_date_time: ~datetime.datetime :ivar recommendation: Alert recommendation. :vartype recommendation: str - :ivar severity: Severity of the alert. Possible values include: "Informational", "Warning", + :ivar severity: Severity of the alert. Known values are: "Informational", "Warning", and "Critical". :vartype severity: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AlertSeverity :ivar error_details: Error details of the alert. @@ -219,38 +229,36 @@ class Alert(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'title': {'readonly': True}, - 'alert_type': {'readonly': True}, - 'appeared_at_date_time': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'severity': {'readonly': True}, - 'error_details': {'readonly': True}, - 'detailed_information': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "title": {"readonly": True}, + "alert_type": {"readonly": True}, + "appeared_at_date_time": {"readonly": True}, + "recommendation": {"readonly": True}, + "severity": {"readonly": True}, + "error_details": {"readonly": True}, + "detailed_information": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'alert_type': {'key': 'properties.alertType', 'type': 'str'}, - 'appeared_at_date_time': {'key': 'properties.appearedAtDateTime', 'type': 'iso-8601'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'error_details': {'key': 'properties.errorDetails', 'type': 'AlertErrorDetails'}, - 'detailed_information': {'key': 'properties.detailedInformation', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "title": {"key": "properties.title", "type": "str"}, + "alert_type": {"key": "properties.alertType", "type": "str"}, + "appeared_at_date_time": {"key": "properties.appearedAtDateTime", "type": "iso-8601"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "severity": {"key": "properties.severity", "type": "str"}, + "error_details": {"key": "properties.errorDetails", "type": "AlertErrorDetails"}, + "detailed_information": {"key": "properties.detailedInformation", "type": "{str}"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None self.title = None self.alert_type = None @@ -261,7 +269,7 @@ def __init__( self.detailed_information = None -class AlertErrorDetails(msrest.serialization.Model): +class AlertErrorDetails(_serialization.Model): """Error details for the alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -275,28 +283,26 @@ class AlertErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_code': {'readonly': True}, - 'error_message': {'readonly': True}, - 'occurrences': {'readonly': True}, + "error_code": {"readonly": True}, + "error_message": {"readonly": True}, + "occurrences": {"readonly": True}, } _attribute_map = { - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'occurrences': {'key': 'occurrences', 'type': 'int'}, + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "occurrences": {"key": "occurrences", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(AlertErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_code = None self.error_message = None self.occurrences = None -class AlertList(msrest.serialization.Model): +class AlertList(_serialization.Model): """Collection of alerts. Variables are only populated by the server, and will be ignored when sending a request. @@ -308,25 +314,23 @@ class AlertList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Alert]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ArcAddon(Addon): +class ArcAddon(Addon): # pylint: disable=too-many-instance-attributes """Arc Addon. Variables are only populated by the server, and will be ignored when sending a request. @@ -339,77 +343,80 @@ class ArcAddon(Addon): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param subscription_id: Required. Arc resource subscription Id. - :type subscription_id: str - :param resource_group_name: Required. Arc resource group name. - :type resource_group_name: str - :param resource_name: Required. Arc resource Name. - :type resource_name: str - :param resource_location: Required. Arc resource location. - :type resource_location: str + :ivar subscription_id: Arc resource subscription Id. Required. + :vartype subscription_id: str + :ivar resource_group_name: Arc resource group name. Required. + :vartype resource_group_name: str + :ivar resource_name: Arc resource Name. Required. + :vartype resource_name: str + :ivar resource_location: Arc resource location. Required. + :vartype resource_location: str :ivar version: Arc resource version. :vartype version: str - :ivar host_platform: Host OS supported by the Arc addon. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the Arc addon. Known values are: "Windows" and "Linux". :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'subscription_id': {'required': True}, - 'resource_group_name': {'required': True}, - 'resource_name': {'required': True}, - 'resource_location': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "subscription_id": {"required": True}, + "resource_group_name": {"required": True}, + "resource_name": {"required": True}, + "resource_location": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'properties.resourceGroupName', 'type': 'str'}, - 'resource_name': {'key': 'properties.resourceName', 'type': 'str'}, - 'resource_location': {'key': 'properties.resourceLocation', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "subscription_id": {"key": "properties.subscriptionId", "type": "str"}, + "resource_group_name": {"key": "properties.resourceGroupName", "type": "str"}, + "resource_name": {"key": "properties.resourceName", "type": "str"}, + "resource_location": {"key": "properties.resourceLocation", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( - self, - *, - subscription_id: str, - resource_group_name: str, - resource_name: str, - resource_location: str, - **kwargs + self, *, subscription_id: str, resource_group_name: str, resource_name: str, resource_location: str, **kwargs ): - super(ArcAddon, self).__init__(**kwargs) - self.kind = 'ArcForKubernetes' # type: str + """ + :keyword subscription_id: Arc resource subscription Id. Required. + :paramtype subscription_id: str + :keyword resource_group_name: Arc resource group name. Required. + :paramtype resource_group_name: str + :keyword resource_name: Arc resource Name. Required. + :paramtype resource_name: str + :keyword resource_location: Arc resource location. Required. + :paramtype resource_location: str + """ + super().__init__(**kwargs) + self.kind: str = "ArcForKubernetes" self.subscription_id = subscription_id self.resource_group_name = resource_group_name self.resource_name = resource_name @@ -420,95 +427,105 @@ def __init__( self.provisioning_state = None -class AsymmetricEncryptedSecret(msrest.serialization.Model): +class AsymmetricEncryptedSecret(_serialization.Model): """Represent the secrets intended for encryption with asymmetric key pair. All required parameters must be populated in order to send to Azure. - :param value: Required. The value of the secret. - :type value: str - :param encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + :ivar value: The value of the secret. Required. + :vartype value: str + :ivar encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the value is unencrypted, it will be null. - :type encryption_cert_thumbprint: str - :param encryption_algorithm: Required. The algorithm used to encrypt "Value". Possible values - include: "None", "AES256", "RSAES_PKCS1_v_1_5". - :type encryption_algorithm: str or + :vartype encryption_cert_thumbprint: str + :ivar encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values are: + "None", "AES256", and "RSAES_PKCS1_v_1_5". + :vartype encryption_algorithm: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EncryptionAlgorithm """ _validation = { - 'value': {'required': True}, - 'encryption_algorithm': {'required': True}, + "value": {"required": True}, + "encryption_algorithm": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'encryption_cert_thumbprint': {'key': 'encryptionCertThumbprint', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "encryption_cert_thumbprint": {"key": "encryptionCertThumbprint", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, } def __init__( self, *, value: str, - encryption_algorithm: Union[str, "EncryptionAlgorithm"], + encryption_algorithm: Union[str, "_models.EncryptionAlgorithm"], encryption_cert_thumbprint: Optional[str] = None, **kwargs ): - super(AsymmetricEncryptedSecret, self).__init__(**kwargs) + """ + :keyword value: The value of the secret. Required. + :paramtype value: str + :keyword encryption_cert_thumbprint: Thumbprint certificate used to encrypt \"Value\". If the + value is unencrypted, it will be null. + :paramtype encryption_cert_thumbprint: str + :keyword encryption_algorithm: The algorithm used to encrypt "Value". Required. Known values + are: "None", "AES256", and "RSAES_PKCS1_v_1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EncryptionAlgorithm + """ + super().__init__(**kwargs) self.value = value self.encryption_cert_thumbprint = encryption_cert_thumbprint self.encryption_algorithm = encryption_algorithm -class Authentication(msrest.serialization.Model): +class Authentication(_serialization.Model): """Authentication mechanism for IoT devices. - :param symmetric_key: Symmetric key for authentication. - :type symmetric_key: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SymmetricKey + :ivar symmetric_key: Symmetric key for authentication. + :vartype symmetric_key: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SymmetricKey """ _attribute_map = { - 'symmetric_key': {'key': 'symmetricKey', 'type': 'SymmetricKey'}, + "symmetric_key": {"key": "symmetricKey", "type": "SymmetricKey"}, } - def __init__( - self, - *, - symmetric_key: Optional["SymmetricKey"] = None, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) + def __init__(self, *, symmetric_key: Optional["_models.SymmetricKey"] = None, **kwargs): + """ + :keyword symmetric_key: Symmetric key for authentication. + :paramtype symmetric_key: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SymmetricKey + """ + super().__init__(**kwargs) self.symmetric_key = symmetric_key -class AzureContainerInfo(msrest.serialization.Model): +class AzureContainerInfo(_serialization.Model): """Azure container mapping of the endpoint. All required parameters must be populated in order to send to Azure. - :param storage_account_credential_id: Required. ID of the storage account credential used to - access storage. - :type storage_account_credential_id: str - :param container_name: Required. Container name (Based on the data format specified, this - represents the name of Azure Files/Page blob/Block blob). - :type container_name: str - :param data_format: Required. Storage format used for the file represented by the share. - Possible values include: "BlockBlob", "PageBlob", "AzureFile". - :type data_format: str or + :ivar storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :vartype storage_account_credential_id: str + :ivar container_name: Container name (Based on the data format specified, this represents the + name of Azure Files/Page blob/Block blob). Required. + :vartype container_name: str + :ivar data_format: Storage format used for the file represented by the share. Required. Known + values are: "BlockBlob", "PageBlob", and "AzureFile". + :vartype data_format: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AzureContainerDataFormat """ _validation = { - 'storage_account_credential_id': {'required': True}, - 'container_name': {'required': True}, - 'data_format': {'required': True}, + "storage_account_credential_id": {"required": True}, + "container_name": {"required": True}, + "data_format": {"required": True}, } _attribute_map = { - 'storage_account_credential_id': {'key': 'storageAccountCredentialId', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'data_format': {'key': 'dataFormat', 'type': 'str'}, + "storage_account_credential_id": {"key": "storageAccountCredentialId", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "data_format": {"key": "dataFormat", "type": "str"}, } def __init__( @@ -516,10 +533,22 @@ def __init__( *, storage_account_credential_id: str, container_name: str, - data_format: Union[str, "AzureContainerDataFormat"], + data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs ): - super(AzureContainerInfo, self).__init__(**kwargs) + """ + :keyword storage_account_credential_id: ID of the storage account credential used to access + storage. Required. + :paramtype storage_account_credential_id: str + :keyword container_name: Container name (Based on the data format specified, this represents + the name of Azure Files/Page blob/Block blob). Required. + :paramtype container_name: str + :keyword data_format: Storage format used for the file represented by the share. Required. + Known values are: "BlockBlob", "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.storage_account_credential_id = storage_account_credential_id self.container_name = container_name self.data_format = data_format @@ -540,48 +569,52 @@ class BandwidthSchedule(ARMBaseModel): :vartype type: str :ivar system_data: Bandwidth object related to ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param start: Required. The start time of the schedule in UTC. - :type start: str - :param stop: Required. The stop time of the schedule in UTC. - :type stop: str - :param rate_in_mbps: Required. The bandwidth rate in Mbps. - :type rate_in_mbps: int - :param days: Required. The days of the week when this schedule is applicable. - :type days: list[str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DayOfWeek] + :ivar start: The start time of the schedule in UTC. Required. + :vartype start: str + :ivar stop: The stop time of the schedule in UTC. Required. + :vartype stop: str + :ivar rate_in_mbps: The bandwidth rate in Mbps. Required. + :vartype rate_in_mbps: int + :ivar days: The days of the week when this schedule is applicable. Required. + :vartype days: list[str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DayOfWeek] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'start': {'required': True}, - 'stop': {'required': True}, - 'rate_in_mbps': {'required': True}, - 'days': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "start": {"required": True}, + "stop": {"required": True}, + "rate_in_mbps": {"required": True}, + "days": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'start': {'key': 'properties.start', 'type': 'str'}, - 'stop': {'key': 'properties.stop', 'type': 'str'}, - 'rate_in_mbps': {'key': 'properties.rateInMbps', 'type': 'int'}, - 'days': {'key': 'properties.days', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "start": {"key": "properties.start", "type": "str"}, + "stop": {"key": "properties.stop", "type": "str"}, + "rate_in_mbps": {"key": "properties.rateInMbps", "type": "int"}, + "days": {"key": "properties.days", "type": "[str]"}, } def __init__( - self, - *, - start: str, - stop: str, - rate_in_mbps: int, - days: List[Union[str, "DayOfWeek"]], - **kwargs + self, *, start: str, stop: str, rate_in_mbps: int, days: List[Union[str, "_models.DayOfWeek"]], **kwargs ): - super(BandwidthSchedule, self).__init__(**kwargs) + """ + :keyword start: The start time of the schedule in UTC. Required. + :paramtype start: str + :keyword stop: The stop time of the schedule in UTC. Required. + :paramtype stop: str + :keyword rate_in_mbps: The bandwidth rate in Mbps. Required. + :paramtype rate_in_mbps: int + :keyword days: The days of the week when this schedule is applicable. Required. + :paramtype days: list[str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DayOfWeek] + """ + super().__init__(**kwargs) self.system_data = None self.start = start self.stop = stop @@ -589,7 +622,7 @@ def __init__( self.days = days -class BandwidthSchedulesList(msrest.serialization.Model): +class BandwidthSchedulesList(_serialization.Model): """The collection of bandwidth schedules. Variables are only populated by the server, and will be ignored when sending a request. @@ -601,55 +634,55 @@ class BandwidthSchedulesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BandwidthSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[BandwidthSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(BandwidthSchedulesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ClientAccessRight(msrest.serialization.Model): +class ClientAccessRight(_serialization.Model): """The mapping between a particular client IP and the type of access client has on the NFS share. All required parameters must be populated in order to send to Azure. - :param client: Required. IP of the client. - :type client: str - :param access_permission: Required. Type of access to be allowed for the client. Possible - values include: "NoAccess", "ReadOnly", "ReadWrite". - :type access_permission: str or + :ivar client: IP of the client. Required. + :vartype client: str + :ivar access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :vartype access_permission: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ClientPermissionType """ _validation = { - 'client': {'required': True}, - 'access_permission': {'required': True}, + "client": {"required": True}, + "access_permission": {"required": True}, } _attribute_map = { - 'client': {'key': 'client', 'type': 'str'}, - 'access_permission': {'key': 'accessPermission', 'type': 'str'}, - } - - def __init__( - self, - *, - client: str, - access_permission: Union[str, "ClientPermissionType"], - **kwargs - ): - super(ClientAccessRight, self).__init__(**kwargs) + "client": {"key": "client", "type": "str"}, + "access_permission": {"key": "accessPermission", "type": "str"}, + } + + def __init__(self, *, client: str, access_permission: Union[str, "_models.ClientPermissionType"], **kwargs): + """ + :keyword client: IP of the client. Required. + :paramtype client: str + :keyword access_permission: Type of access to be allowed for the client. Required. Known values + are: "NoAccess", "ReadOnly", and "ReadWrite". + :paramtype access_permission: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ClientPermissionType + """ + super().__init__(**kwargs) self.client = client self.access_permission = access_permission @@ -657,8 +690,8 @@ def __init__( class Role(ARMBaseModel): """Compute role. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CloudEdgeManagementRole, IoTRole, KubernetesRole, MECRole Variables are only populated by the server, and will be ignored when sending a request. @@ -670,39 +703,42 @@ class Role(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } _subtype_map = { - 'kind': {'CloudEdgeManagement': 'CloudEdgeManagementRole', 'IOT': 'IoTRole', 'Kubernetes': 'KubernetesRole', 'MEC': 'MECRole'} - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.kind = 'Role' # type: str + "kind": { + "CloudEdgeManagement": "CloudEdgeManagementRole", + "IOT": "IoTRole", + "Kubernetes": "KubernetesRole", + "MEC": "MECRole", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None self.system_data = None @@ -719,72 +755,71 @@ class CloudEdgeManagementRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :ivar local_management_status: Local Edge Management Status. Possible values include: - "Enabled", "Disabled". + :ivar local_management_status: Local Edge Management Status. Known values are: "Enabled" and + "Disabled". :vartype local_management_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus :ivar edge_profile: Edge Profile of the resource. :vartype edge_profile: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfile - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'local_management_status': {'readonly': True}, - 'edge_profile': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "local_management_status": {"readonly": True}, + "edge_profile": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'local_management_status': {'key': 'properties.localManagementStatus', 'type': 'str'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, - } - - def __init__( - self, - *, - role_status: Optional[Union[str, "RoleStatus"]] = None, - **kwargs - ): - super(CloudEdgeManagementRole, self).__init__(**kwargs) - self.kind = 'CloudEdgeManagement' # type: str + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "local_management_status": {"key": "properties.localManagementStatus", "type": "str"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, + } + + def __init__(self, *, role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs): + """ + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "CloudEdgeManagement" self.local_management_status = None self.edge_profile = None self.role_status = role_status -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.CloudErrorBody] + :vartype message: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.CloudErrorBody] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -792,16 +827,26 @@ def __init__( *, code: Optional[str] = None, message: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): - super(CloudErrorBody, self).__init__(**kwargs) + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.CloudErrorBody] + """ + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class CniConfig(msrest.serialization.Model): +class CniConfig(_serialization.Model): """Cni configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -817,102 +862,102 @@ class CniConfig(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, - 'pod_subnet': {'readonly': True}, - 'service_subnet': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, + "pod_subnet": {"readonly": True}, + "service_subnet": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'pod_subnet': {'key': 'podSubnet', 'type': 'str'}, - 'service_subnet': {'key': 'serviceSubnet', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "pod_subnet": {"key": "podSubnet", "type": "str"}, + "service_subnet": {"key": "serviceSubnet", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(CniConfig, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None self.pod_subnet = None self.service_subnet = None -class ComputeResource(msrest.serialization.Model): +class ComputeResource(_serialization.Model): """Compute infrastructure Resource. All required parameters must be populated in order to send to Azure. - :param processor_count: Required. Processor count. - :type processor_count: int - :param memory_in_gb: Required. Memory in GB. - :type memory_in_gb: long + :ivar processor_count: Processor count. Required. + :vartype processor_count: int + :ivar memory_in_gb: Memory in GB. Required. + :vartype memory_in_gb: int """ _validation = { - 'processor_count': {'required': True}, - 'memory_in_gb': {'required': True}, + "processor_count": {"required": True}, + "memory_in_gb": {"required": True}, } _attribute_map = { - 'processor_count': {'key': 'processorCount', 'type': 'int'}, - 'memory_in_gb': {'key': 'memoryInGB', 'type': 'long'}, - } - - def __init__( - self, - *, - processor_count: int, - memory_in_gb: int, - **kwargs - ): - super(ComputeResource, self).__init__(**kwargs) + "processor_count": {"key": "processorCount", "type": "int"}, + "memory_in_gb": {"key": "memoryInGB", "type": "int"}, + } + + def __init__(self, *, processor_count: int, memory_in_gb: int, **kwargs): + """ + :keyword processor_count: Processor count. Required. + :paramtype processor_count: int + :keyword memory_in_gb: Memory in GB. Required. + :paramtype memory_in_gb: int + """ + super().__init__(**kwargs) self.processor_count = processor_count self.memory_in_gb = memory_in_gb -class ContactDetails(msrest.serialization.Model): +class ContactDetails(_serialization.Model): """Contains all the contact details of the customer. All required parameters must be populated in order to send to Azure. - :param contact_person: Required. The contact person name. - :type contact_person: str - :param company_name: Required. The name of the company. - :type company_name: str - :param phone: Required. The phone number. - :type phone: str - :param email_list: Required. The email list. - :type email_list: list[str] + :ivar contact_person: The contact person name. Required. + :vartype contact_person: str + :ivar company_name: The name of the company. Required. + :vartype company_name: str + :ivar phone: The phone number. Required. + :vartype phone: str + :ivar email_list: The email list. Required. + :vartype email_list: list[str] """ _validation = { - 'contact_person': {'required': True}, - 'company_name': {'required': True}, - 'phone': {'required': True}, - 'email_list': {'required': True}, + "contact_person": {"required": True}, + "company_name": {"required": True}, + "phone": {"required": True}, + "email_list": {"required": True}, } _attribute_map = { - 'contact_person': {'key': 'contactPerson', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'phone': {'key': 'phone', 'type': 'str'}, - 'email_list': {'key': 'emailList', 'type': '[str]'}, - } - - def __init__( - self, - *, - contact_person: str, - company_name: str, - phone: str, - email_list: List[str], - **kwargs - ): - super(ContactDetails, self).__init__(**kwargs) + "contact_person": {"key": "contactPerson", "type": "str"}, + "company_name": {"key": "companyName", "type": "str"}, + "phone": {"key": "phone", "type": "str"}, + "email_list": {"key": "emailList", "type": "[str]"}, + } + + def __init__(self, *, contact_person: str, company_name: str, phone: str, email_list: List[str], **kwargs): + """ + :keyword contact_person: The contact person name. Required. + :paramtype contact_person: str + :keyword company_name: The name of the company. Required. + :paramtype company_name: str + :keyword phone: The phone number. Required. + :paramtype phone: str + :keyword email_list: The email list. Required. + :paramtype email_list: list[str] + """ + super().__init__(**kwargs) self.contact_person = contact_person self.company_name = company_name self.phone = phone @@ -934,13 +979,13 @@ class Container(ARMBaseModel): :vartype type: str :ivar system_data: Container in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :ivar container_status: Current status of the container. Possible values include: "OK", - "Offline", "Unknown", "Updating", "NeedsAttention". + :ivar container_status: Current status of the container. Known values are: "OK", "Offline", + "Unknown", "Updating", and "NeedsAttention". :vartype container_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ContainerStatus - :param data_format: Required. DataFormat for Container. Possible values include: "BlockBlob", - "PageBlob", "AzureFile". - :type data_format: str or + :ivar data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :vartype data_format: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AzureContainerDataFormat :ivar refresh_details: Details of the refresh job on this container. :vartype refresh_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RefreshDetails @@ -949,34 +994,35 @@ class Container(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'container_status': {'readonly': True}, - 'data_format': {'required': True}, - 'refresh_details': {'readonly': True}, - 'created_date_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "container_status": {"readonly": True}, + "data_format": {"required": True}, + "refresh_details": {"readonly": True}, + "created_date_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'container_status': {'key': 'properties.containerStatus', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - data_format: Union[str, "AzureContainerDataFormat"], - **kwargs - ): - super(Container, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "container_status": {"key": "properties.containerStatus", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, + } + + def __init__(self, *, data_format: Union[str, "_models.AzureContainerDataFormat"], **kwargs): + """ + :keyword data_format: DataFormat for Container. Required. Known values are: "BlockBlob", + "PageBlob", and "AzureFile". + :paramtype data_format: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AzureContainerDataFormat + """ + super().__init__(**kwargs) self.system_data = None self.container_status = None self.data_format = data_format @@ -984,7 +1030,7 @@ def __init__( self.created_date_time = None -class ContainerList(msrest.serialization.Model): +class ContainerList(_serialization.Model): """Collection of all the containers on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -996,25 +1042,23 @@ class ContainerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Container]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Container]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ContainerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevice(ARMBaseModel): +class DataBoxEdgeDevice(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1027,29 +1071,29 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param location: Required. The location of the device. This is a supported and registered Azure + :ivar location: The location of the device. This is a supported and registered Azure geographical region (for example, West US, East US, or Southeast Asia). The geographical region of a device cannot be changed once it is created, but if an identical geographical region is - specified on update, the request will succeed. - :type location: str - :param tags: A set of tags. The list of tags that describe the device. These tags can be used - to view and group this device (across resource groups). - :type tags: dict[str, str] - :param sku: The SKU type. - :type sku: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Sku - :param etag: The etag for the devices. - :type etag: str - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceIdentity - :ivar kind: The etag for the devices. Possible values include: "AzureDataBoxGateway", - "AzureStackEdge", "AzureStackHub", "AzureModularDataCentre". + specified on update, the request will succeed. Required. + :vartype location: str + :ivar tags: The list of tags that describe the device. These tags can be used to view and group + this device (across resource groups). + :vartype tags: dict[str, str] + :ivar sku: The SKU type. + :vartype sku: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Sku + :ivar etag: The etag for the devices. + :vartype etag: str + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceIdentity + :ivar kind: The etag for the devices. Known values are: "AzureDataBoxGateway", + "AzureStackEdge", "AzureStackHub", and "AzureModularDataCentre". :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceKind :ivar system_data: DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Possible - values include: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", - "PartiallyDisconnected", "Maintenance". - :type data_box_edge_device_status: str or + :ivar data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known values + are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :vartype data_box_edge_device_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceStatus :ivar serial_number: The Serial Number of Data Box Edge/Gateway device. :vartype serial_number: str @@ -1057,8 +1101,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :vartype description: str :ivar model_description: The description of the Data Box Edge/Gateway device model. :vartype model_description: str - :ivar device_type: The type of the Data Box Edge/Gateway device. Possible values include: - "DataBoxEdgeDevice". + :ivar device_type: The type of the Data Box Edge/Gateway device. "DataBoxEdgeDevice" :vartype device_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DeviceType :ivar friendly_name: The Data Box Edge/Gateway device name. :vartype friendly_name: str @@ -1069,7 +1112,7 @@ class DataBoxEdgeDevice(ARMBaseModel): :ivar device_software_version: The Data Box Edge/Gateway device software version. :vartype device_software_version: str :ivar device_local_capacity: The Data Box Edge/Gateway device local capacity in MB. - :vartype device_local_capacity: long + :vartype device_local_capacity: int :ivar time_zone: The Data Box Edge/Gateway device timezone. :vartype time_zone: str :ivar device_hcs_version: The device software version number of the device (eg: 1.2.18105.6). @@ -1087,70 +1130,91 @@ class DataBoxEdgeDevice(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'system_data': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'description': {'readonly': True}, - 'model_description': {'readonly': True}, - 'device_type': {'readonly': True}, - 'friendly_name': {'readonly': True}, - 'culture': {'readonly': True}, - 'device_model': {'readonly': True}, - 'device_software_version': {'readonly': True}, - 'device_local_capacity': {'readonly': True}, - 'time_zone': {'readonly': True}, - 'device_hcs_version': {'readonly': True}, - 'configured_role_types': {'readonly': True}, - 'node_count': {'readonly': True}, - 'resource_move_details': {'readonly': True}, - 'edge_profile': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "kind": {"readonly": True}, + "system_data": {"readonly": True}, + "serial_number": {"readonly": True}, + "description": {"readonly": True}, + "model_description": {"readonly": True}, + "device_type": {"readonly": True}, + "friendly_name": {"readonly": True}, + "culture": {"readonly": True}, + "device_model": {"readonly": True}, + "device_software_version": {"readonly": True}, + "device_local_capacity": {"readonly": True}, + "time_zone": {"readonly": True}, + "device_hcs_version": {"readonly": True}, + "configured_role_types": {"readonly": True}, + "node_count": {"readonly": True}, + "resource_move_details": {"readonly": True}, + "edge_profile": {"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}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'data_box_edge_device_status': {'key': 'properties.dataBoxEdgeDeviceStatus', 'type': 'str'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'model_description': {'key': 'properties.modelDescription', 'type': 'str'}, - 'device_type': {'key': 'properties.deviceType', 'type': 'str'}, - 'friendly_name': {'key': 'properties.friendlyName', 'type': 'str'}, - 'culture': {'key': 'properties.culture', 'type': 'str'}, - 'device_model': {'key': 'properties.deviceModel', 'type': 'str'}, - 'device_software_version': {'key': 'properties.deviceSoftwareVersion', 'type': 'str'}, - 'device_local_capacity': {'key': 'properties.deviceLocalCapacity', 'type': 'long'}, - 'time_zone': {'key': 'properties.timeZone', 'type': 'str'}, - 'device_hcs_version': {'key': 'properties.deviceHcsVersion', 'type': 'str'}, - 'configured_role_types': {'key': 'properties.configuredRoleTypes', 'type': '[str]'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - 'resource_move_details': {'key': 'properties.resourceMoveDetails', 'type': 'ResourceMoveDetails'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfile'}, - } - - def __init__( + "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}"}, + "sku": {"key": "sku", "type": "Sku"}, + "etag": {"key": "etag", "type": "str"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "data_box_edge_device_status": {"key": "properties.dataBoxEdgeDeviceStatus", "type": "str"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "model_description": {"key": "properties.modelDescription", "type": "str"}, + "device_type": {"key": "properties.deviceType", "type": "str"}, + "friendly_name": {"key": "properties.friendlyName", "type": "str"}, + "culture": {"key": "properties.culture", "type": "str"}, + "device_model": {"key": "properties.deviceModel", "type": "str"}, + "device_software_version": {"key": "properties.deviceSoftwareVersion", "type": "str"}, + "device_local_capacity": {"key": "properties.deviceLocalCapacity", "type": "int"}, + "time_zone": {"key": "properties.timeZone", "type": "str"}, + "device_hcs_version": {"key": "properties.deviceHcsVersion", "type": "str"}, + "configured_role_types": {"key": "properties.configuredRoleTypes", "type": "[str]"}, + "node_count": {"key": "properties.nodeCount", "type": "int"}, + "resource_move_details": {"key": "properties.resourceMoveDetails", "type": "ResourceMoveDetails"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfile"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, etag: Optional[str] = None, - identity: Optional["ResourceIdentity"] = None, - data_box_edge_device_status: Optional[Union[str, "DataBoxEdgeDeviceStatus"]] = None, + identity: Optional["_models.ResourceIdentity"] = None, + data_box_edge_device_status: Optional[Union[str, "_models.DataBoxEdgeDeviceStatus"]] = None, **kwargs ): - super(DataBoxEdgeDevice, self).__init__(**kwargs) + """ + :keyword location: The location of the device. This is a supported and registered Azure + geographical region (for example, West US, East US, or Southeast Asia). The geographical region + of a device cannot be changed once it is created, but if an identical geographical region is + specified on update, the request will succeed. Required. + :paramtype location: str + :keyword tags: The list of tags that describe the device. These tags can be used to view and + group this device (across resource groups). + :paramtype tags: dict[str, str] + :keyword sku: The SKU type. + :paramtype sku: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Sku + :keyword etag: The etag for the devices. + :paramtype etag: str + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceIdentity + :keyword data_box_edge_device_status: The status of the Data Box Edge/Gateway device. Known + values are: "ReadyToSetup", "Online", "Offline", "NeedsAttention", "Disconnected", + "PartiallyDisconnected", and "Maintenance". + :paramtype data_box_edge_device_status: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceStatus + """ + super().__init__(**kwargs) self.location = location self.tags = tags self.sku = sku @@ -1176,7 +1240,7 @@ def __init__( self.edge_profile = None -class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): +class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The extended Info of the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -1187,27 +1251,27 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param encryption_key_thumbprint: The digital signature of encrypted certificate. - :type encryption_key_thumbprint: str - :param encryption_key: The public part of the encryption certificate. Client uses this to + :ivar encryption_key_thumbprint: The digital signature of encrypted certificate. + :vartype encryption_key_thumbprint: str + :ivar encryption_key: The public part of the encryption certificate. Client uses this to encrypt any secret. - :type encryption_key: str + :vartype encryption_key: str :ivar resource_key: The Resource ID of the Resource. :vartype resource_key: str - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_version: str - :param key_vault_sync_status: Key vault sync status. Possible values include: "KeyVaultSynced", - "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", "KeyVaultSyncing", + :vartype channel_integrity_key_version: str + :ivar key_vault_sync_status: Key vault sync status. Known values are: "KeyVaultSynced", + "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", "KeyVaultSyncing", and "KeyVaultNotSynced". - :type key_vault_sync_status: str or + :vartype key_vault_sync_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KeyVaultSyncStatus :ivar device_secrets: Device secrets, will be returned only with ODataFilter $expand=deviceSecrets. @@ -1215,26 +1279,26 @@ class DataBoxEdgeDeviceExtendedInfo(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource_key': {'readonly': True}, - 'device_secrets': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource_key": {"readonly": True}, + "device_secrets": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'encryption_key_thumbprint': {'key': 'properties.encryptionKeyThumbprint', 'type': 'str'}, - 'encryption_key': {'key': 'properties.encryptionKey', 'type': 'str'}, - 'resource_key': {'key': 'properties.resourceKey', 'type': 'str'}, - 'client_secret_store_id': {'key': 'properties.clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'properties.clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'properties.channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'properties.channelIntegrityKeyVersion', 'type': 'str'}, - 'key_vault_sync_status': {'key': 'properties.keyVaultSyncStatus', 'type': 'str'}, - 'device_secrets': {'key': 'properties.deviceSecrets', 'type': '{Secret}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "encryption_key_thumbprint": {"key": "properties.encryptionKeyThumbprint", "type": "str"}, + "encryption_key": {"key": "properties.encryptionKey", "type": "str"}, + "resource_key": {"key": "properties.resourceKey", "type": "str"}, + "client_secret_store_id": {"key": "properties.clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "properties.clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "properties.channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "properties.channelIntegrityKeyVersion", "type": "str"}, + "key_vault_sync_status": {"key": "properties.keyVaultSyncStatus", "type": "str"}, + "device_secrets": {"key": "properties.deviceSecrets", "type": "{Secret}"}, } def __init__( @@ -1246,10 +1310,32 @@ def __init__( client_secret_store_url: Optional[str] = None, channel_integrity_key_name: Optional[str] = None, channel_integrity_key_version: Optional[str] = None, - key_vault_sync_status: Optional[Union[str, "KeyVaultSyncStatus"]] = None, + key_vault_sync_status: Optional[Union[str, "_models.KeyVaultSyncStatus"]] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfo, self).__init__(**kwargs) + """ + :keyword encryption_key_thumbprint: The digital signature of encrypted certificate. + :paramtype encryption_key_thumbprint: str + :keyword encryption_key: The public part of the encryption certificate. Client uses this to + encrypt any secret. + :paramtype encryption_key: str + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name of Channel Integrity Key stored in the Client Key + Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + :keyword key_vault_sync_status: Key vault sync status. Known values are: "KeyVaultSynced", + "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", "KeyVaultSyncing", and + "KeyVaultNotSynced". + :paramtype key_vault_sync_status: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KeyVaultSyncStatus + """ + super().__init__(**kwargs) self.encryption_key_thumbprint = encryption_key_thumbprint self.encryption_key = encryption_key self.resource_key = None @@ -1261,32 +1347,33 @@ def __init__( self.device_secrets = None -class DataBoxEdgeDeviceExtendedInfoPatch(msrest.serialization.Model): +class DataBoxEdgeDeviceExtendedInfoPatch(_serialization.Model): """The Data Box Edge/Gateway device extended info patch. - :param client_secret_store_id: The Key Vault ARM Id for client secrets. - :type client_secret_store_id: str - :param client_secret_store_url: The url to access the Client Key Vault. - :type client_secret_store_url: str - :param channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key + :ivar client_secret_store_id: The Key Vault ARM Id for client secrets. + :vartype client_secret_store_id: str + :ivar client_secret_store_url: The url to access the Client Key Vault. + :vartype client_secret_store_url: str + :ivar channel_integrity_key_name: The name for Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_name: str - :param channel_integrity_key_version: The version of Channel Integrity Key stored in the Client + :vartype channel_integrity_key_name: str + :ivar channel_integrity_key_version: The version of Channel Integrity Key stored in the Client Key Vault. - :type channel_integrity_key_version: str - :param sync_status: For changing or to initiate the resync to key-vault set the status to - KeyVaultSyncPending, rest of the status will not be applicable. Possible values include: + :vartype channel_integrity_key_version: str + :ivar sync_status: For changing or to initiate the resync to key-vault set the status to + KeyVaultSyncPending, rest of the status will not be applicable. Known values are: "KeyVaultSynced", "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", - "KeyVaultSyncing", "KeyVaultNotSynced". - :type sync_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KeyVaultSyncStatus + "KeyVaultSyncing", and "KeyVaultNotSynced". + :vartype sync_status: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KeyVaultSyncStatus """ _attribute_map = { - 'client_secret_store_id': {'key': 'clientSecretStoreId', 'type': 'str'}, - 'client_secret_store_url': {'key': 'clientSecretStoreUrl', 'type': 'str'}, - 'channel_integrity_key_name': {'key': 'channelIntegrityKeyName', 'type': 'str'}, - 'channel_integrity_key_version': {'key': 'channelIntegrityKeyVersion', 'type': 'str'}, - 'sync_status': {'key': 'syncStatus', 'type': 'str'}, + "client_secret_store_id": {"key": "clientSecretStoreId", "type": "str"}, + "client_secret_store_url": {"key": "clientSecretStoreUrl", "type": "str"}, + "channel_integrity_key_name": {"key": "channelIntegrityKeyName", "type": "str"}, + "channel_integrity_key_version": {"key": "channelIntegrityKeyVersion", "type": "str"}, + "sync_status": {"key": "syncStatus", "type": "str"}, } def __init__( @@ -1296,10 +1383,28 @@ def __init__( client_secret_store_url: Optional[str] = None, channel_integrity_key_name: Optional[str] = None, channel_integrity_key_version: Optional[str] = None, - sync_status: Optional[Union[str, "KeyVaultSyncStatus"]] = None, + sync_status: Optional[Union[str, "_models.KeyVaultSyncStatus"]] = None, **kwargs ): - super(DataBoxEdgeDeviceExtendedInfoPatch, self).__init__(**kwargs) + """ + :keyword client_secret_store_id: The Key Vault ARM Id for client secrets. + :paramtype client_secret_store_id: str + :keyword client_secret_store_url: The url to access the Client Key Vault. + :paramtype client_secret_store_url: str + :keyword channel_integrity_key_name: The name for Channel Integrity Key stored in the Client + Key Vault. + :paramtype channel_integrity_key_name: str + :keyword channel_integrity_key_version: The version of Channel Integrity Key stored in the + Client Key Vault. + :paramtype channel_integrity_key_version: str + :keyword sync_status: For changing or to initiate the resync to key-vault set the status to + KeyVaultSyncPending, rest of the status will not be applicable. Known values are: + "KeyVaultSynced", "KeyVaultSyncFailed", "KeyVaultNotConfigured", "KeyVaultSyncPending", + "KeyVaultSyncing", and "KeyVaultNotSynced". + :paramtype sync_status: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KeyVaultSyncStatus + """ + super().__init__(**kwargs) self.client_secret_store_id = client_secret_store_id self.client_secret_store_url = client_secret_store_url self.channel_integrity_key_name = channel_integrity_key_name @@ -1307,7 +1412,7 @@ def __init__( self.sync_status = sync_status -class DataBoxEdgeDeviceList(msrest.serialization.Model): +class DataBoxEdgeDeviceList(_serialization.Model): """The collection of Data Box Edge/Gateway devices. Variables are only populated by the server, and will be ignored when sending a request. @@ -1319,104 +1424,110 @@ class DataBoxEdgeDeviceList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeDevice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeDeviceList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataBoxEdgeDevicePatch(msrest.serialization.Model): +class DataBoxEdgeDevicePatch(_serialization.Model): """The Data Box Edge/Gateway device patch. - :param tags: A set of tags. The tags attached to the Data Box Edge/Gateway resource. - :type tags: dict[str, str] - :param identity: Msi identity of the resource. - :type identity: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceIdentity - :param edge_profile: Edge Profile property of the Data Box Edge/Gateway device. - :type edge_profile: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfilePatch + :ivar tags: The tags attached to the Data Box Edge/Gateway resource. + :vartype tags: dict[str, str] + :ivar identity: Msi identity of the resource. + :vartype identity: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceIdentity + :ivar edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :vartype edge_profile: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfilePatch """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'edge_profile': {'key': 'properties.edgeProfile', 'type': 'EdgeProfilePatch'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, + "edge_profile": {"key": "properties.edgeProfile", "type": "EdgeProfilePatch"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["ResourceIdentity"] = None, - edge_profile: Optional["EdgeProfilePatch"] = None, + identity: Optional["_models.ResourceIdentity"] = None, + edge_profile: Optional["_models.EdgeProfilePatch"] = None, **kwargs ): - super(DataBoxEdgeDevicePatch, self).__init__(**kwargs) + """ + :keyword tags: The tags attached to the Data Box Edge/Gateway resource. + :paramtype tags: dict[str, str] + :keyword identity: Msi identity of the resource. + :paramtype identity: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceIdentity + :keyword edge_profile: Edge Profile property of the Data Box Edge/Gateway device. + :paramtype edge_profile: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfilePatch + """ + super().__init__(**kwargs) self.tags = tags self.identity = identity self.edge_profile = edge_profile -class DataBoxEdgeMoveRequest(msrest.serialization.Model): +class DataBoxEdgeMoveRequest(_serialization.Model): """Resource Move details. All required parameters must be populated in order to send to Azure. - :param target_resource_group: Required. Target resource group ARMId. - :type target_resource_group: str - :param resources: Required. List of resources to be moved. - :type resources: list[str] + :ivar target_resource_group: Target resource group ARMId. Required. + :vartype target_resource_group: str + :ivar resources: List of resources to be moved. Required. + :vartype resources: list[str] """ _validation = { - 'target_resource_group': {'required': True}, - 'resources': {'required': True}, + "target_resource_group": {"required": True}, + "resources": {"required": True}, } _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'resources': {'key': 'resources', 'type': '[str]'}, - } - - def __init__( - self, - *, - target_resource_group: str, - resources: List[str], - **kwargs - ): - super(DataBoxEdgeMoveRequest, self).__init__(**kwargs) + "target_resource_group": {"key": "targetResourceGroup", "type": "str"}, + "resources": {"key": "resources", "type": "[str]"}, + } + + def __init__(self, *, target_resource_group: str, resources: List[str], **kwargs): + """ + :keyword target_resource_group: Target resource group ARMId. Required. + :paramtype target_resource_group: str + :keyword resources: List of resources to be moved. Required. + :paramtype resources: list[str] + """ + super().__init__(**kwargs) self.target_resource_group = target_resource_group self.resources = resources -class DataBoxEdgeSku(msrest.serialization.Model): +class DataBoxEdgeSku(_serialization.Model): # pylint: disable=too-many-instance-attributes """The Sku information. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of the resource. :vartype resource_type: str - :ivar name: The Sku name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", - "EP2_256_2T4_W", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC", "Management". + :ivar name: The Sku name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", "EP2_256_2T4_W", "EdgeMR_Mini", + "RCA_Small", "RCA_Large", "RDC", and "Management". :vartype name: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuName :ivar kind: The Sku kind. :vartype kind: str - :ivar tier: The Sku tier. Possible values include: "Standard". + :ivar tier: The Sku tier. "Standard" :vartype tier: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuTier :ivar size: The Sku kind. :vartype size: str @@ -1431,61 +1542,63 @@ class DataBoxEdgeSku(msrest.serialization.Model): list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuLocationInfo] :ivar costs: The pricing info of the Sku. :vartype costs: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuCost] - :ivar signup_option: Sku can be signed up by customer or not. Possible values include: "None", + :ivar signup_option: Sku can be signed up by customer or not. Known values are: "None" and "Available". :vartype signup_option: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuSignupOption - :ivar version: Availability of the Sku as preview/stable. Possible values include: "Stable", + :ivar version: Availability of the Sku as preview/stable. Known values are: "Stable" and "Preview". :vartype version: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuVersion - :ivar availability: Links to the next set of results. Possible values include: "Available", + :ivar availability: Links to the next set of results. Known values are: "Available" and "Unavailable". :vartype availability: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuAvailability :ivar shipment_types: List of Shipment Types supported by this SKU. :vartype shipment_types: list[str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShipmentType] + :ivar capabilities: The capability info of the SKU. + :vartype capabilities: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuCapability] """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True}, - 'tier': {'readonly': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, - 'locations': {'readonly': True}, - 'api_versions': {'readonly': True}, - 'location_info': {'readonly': True}, - 'costs': {'readonly': True}, - 'signup_option': {'readonly': True}, - 'version': {'readonly': True}, - 'availability': {'readonly': True}, - 'shipment_types': {'readonly': True}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "kind": {"readonly": True}, + "tier": {"readonly": True}, + "size": {"readonly": True}, + "family": {"readonly": True}, + "locations": {"readonly": True}, + "api_versions": {"readonly": True}, + "location_info": {"readonly": True}, + "costs": {"readonly": True}, + "signup_option": {"readonly": True}, + "version": {"readonly": True}, + "availability": {"readonly": True}, + "shipment_types": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'signup_option': {'key': 'signupOption', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'availability': {'key': 'availability', 'type': 'str'}, - 'shipment_types': {'key': 'shipmentTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSku, self).__init__(**kwargs) + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "api_versions": {"key": "apiVersions", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "signup_option": {"key": "signupOption", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "availability": {"key": "availability", "type": "str"}, + "shipment_types": {"key": "shipmentTypes", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SkuCapability]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.kind = None @@ -1500,9 +1613,10 @@ def __init__( self.version = None self.availability = None self.shipment_types = None + self.capabilities = None -class DataBoxEdgeSkuList(msrest.serialization.Model): +class DataBoxEdgeSkuList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -1514,144 +1628,166 @@ class DataBoxEdgeSkuList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataBoxEdgeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataBoxEdgeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DataBoxEdgeSkuList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DCAccessCode(msrest.serialization.Model): +class DCAccessCode(_serialization.Model): """DC Access code in the case of Self Managed Shipping. - :param auth_code: DCAccess Code for the Self Managed shipment. - :type auth_code: str + :ivar auth_code: DCAccess Code for the Self Managed shipment. + :vartype auth_code: str """ _attribute_map = { - 'auth_code': {'key': 'properties.authCode', 'type': 'str'}, + "auth_code": {"key": "properties.authCode", "type": "str"}, } - def __init__( - self, - *, - auth_code: Optional[str] = None, - **kwargs - ): - super(DCAccessCode, self).__init__(**kwargs) + def __init__(self, *, auth_code: Optional[str] = None, **kwargs): + """ + :keyword auth_code: DCAccess Code for the Self Managed shipment. + :paramtype auth_code: str + """ + super().__init__(**kwargs) self.auth_code = auth_code -class EdgeProfile(msrest.serialization.Model): +class EdgeProfile(_serialization.Model): """Details about Edge Profile for the resource. - :param subscription: Edge Profile Subscription. - :type subscription: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfileSubscription + :ivar subscription: Edge Profile Subscription. + :vartype subscription: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfileSubscription """ _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscription'}, + "subscription": {"key": "subscription", "type": "EdgeProfileSubscription"}, } - def __init__( - self, - *, - subscription: Optional["EdgeProfileSubscription"] = None, - **kwargs - ): - super(EdgeProfile, self).__init__(**kwargs) + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscription"] = None, **kwargs): + """ + :keyword subscription: Edge Profile Subscription. + :paramtype subscription: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfileSubscription + """ + super().__init__(**kwargs) self.subscription = subscription -class EdgeProfilePatch(msrest.serialization.Model): +class EdgeProfilePatch(_serialization.Model): """The Data Box Edge/Gateway Edge Profile patch. - :param subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. - :type subscription: + :ivar subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :vartype subscription: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfileSubscriptionPatch """ _attribute_map = { - 'subscription': {'key': 'subscription', 'type': 'EdgeProfileSubscriptionPatch'}, + "subscription": {"key": "subscription", "type": "EdgeProfileSubscriptionPatch"}, } - def __init__( - self, - *, - subscription: Optional["EdgeProfileSubscriptionPatch"] = None, - **kwargs - ): - super(EdgeProfilePatch, self).__init__(**kwargs) + def __init__(self, *, subscription: Optional["_models.EdgeProfileSubscriptionPatch"] = None, **kwargs): + """ + :keyword subscription: The Data Box Edge/Gateway Edge Profile Subscription patch. + :paramtype subscription: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EdgeProfileSubscriptionPatch + """ + super().__init__(**kwargs) self.subscription = subscription -class EdgeProfileSubscription(msrest.serialization.Model): +class EdgeProfileSubscription(_serialization.Model): """Subscription details for the Edge Profile. - :param registration_id: Edge Subscription Registration ID. - :type registration_id: str - :param id: ARM ID of the subscription. - :type id: str - :param state: Possible values include: "Registered", "Warned", "Suspended", "Deleted", + :ivar registration_id: Edge Subscription Registration ID. + :vartype registration_id: str + :ivar id: ARM ID of the subscription. + :vartype id: str + :ivar state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and "Unregistered". - :type state: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SubscriptionState - :param registration_date: - :type registration_date: str - :param subscription_id: - :type subscription_id: str - :param tenant_id: - :type tenant_id: str - :param location_placement_id: - :type location_placement_id: str - :param quota_id: - :type quota_id: str - :param serialized_details: - :type serialized_details: str - :param registered_features: - :type registered_features: + :vartype state: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SubscriptionState + :ivar registration_date: + :vartype registration_date: str + :ivar subscription_id: + :vartype subscription_id: str + :ivar tenant_id: + :vartype tenant_id: str + :ivar location_placement_id: + :vartype location_placement_id: str + :ivar quota_id: + :vartype quota_id: str + :ivar serialized_details: + :vartype serialized_details: str + :ivar registered_features: + :vartype registered_features: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SubscriptionRegisteredFeatures] """ _attribute_map = { - 'registration_id': {'key': 'registrationId', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'registration_date': {'key': 'registrationDate', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'location_placement_id': {'key': 'properties.locationPlacementId', 'type': 'str'}, - 'quota_id': {'key': 'properties.quotaId', 'type': 'str'}, - 'serialized_details': {'key': 'properties.serializedDetails', 'type': 'str'}, - 'registered_features': {'key': 'properties.registeredFeatures', 'type': '[SubscriptionRegisteredFeatures]'}, + "registration_id": {"key": "registrationId", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "registration_date": {"key": "registrationDate", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "location_placement_id": {"key": "properties.locationPlacementId", "type": "str"}, + "quota_id": {"key": "properties.quotaId", "type": "str"}, + "serialized_details": {"key": "properties.serializedDetails", "type": "str"}, + "registered_features": {"key": "properties.registeredFeatures", "type": "[SubscriptionRegisteredFeatures]"}, } def __init__( self, *, registration_id: Optional[str] = None, - id: Optional[str] = None, - state: Optional[Union[str, "SubscriptionState"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + state: Optional[Union[str, "_models.SubscriptionState"]] = None, registration_date: Optional[str] = None, subscription_id: Optional[str] = None, tenant_id: Optional[str] = None, location_placement_id: Optional[str] = None, quota_id: Optional[str] = None, serialized_details: Optional[str] = None, - registered_features: Optional[List["SubscriptionRegisteredFeatures"]] = None, + registered_features: Optional[List["_models.SubscriptionRegisteredFeatures"]] = None, **kwargs ): - super(EdgeProfileSubscription, self).__init__(**kwargs) + """ + :keyword registration_id: Edge Subscription Registration ID. + :paramtype registration_id: str + :keyword id: ARM ID of the subscription. + :paramtype id: str + :keyword state: Known values are: "Registered", "Warned", "Suspended", "Deleted", and + "Unregistered". + :paramtype state: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SubscriptionState + :keyword registration_date: + :paramtype registration_date: str + :keyword subscription_id: + :paramtype subscription_id: str + :keyword tenant_id: + :paramtype tenant_id: str + :keyword location_placement_id: + :paramtype location_placement_id: str + :keyword quota_id: + :paramtype quota_id: str + :keyword serialized_details: + :paramtype serialized_details: str + :keyword registered_features: + :paramtype registered_features: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.SubscriptionRegisteredFeatures] + """ + super().__init__(**kwargs) self.registration_id = registration_id self.id = id self.state = state @@ -1664,28 +1800,27 @@ def __init__( self.registered_features = registered_features -class EdgeProfileSubscriptionPatch(msrest.serialization.Model): +class EdgeProfileSubscriptionPatch(_serialization.Model): """The Data Box Edge/Gateway Edge Profile Subscription patch. - :param id: The path ID that uniquely identifies the subscription of the edge profile. - :type id: str + :ivar id: The path ID that uniquely identifies the subscription of the edge profile. + :vartype id: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): - super(EdgeProfileSubscriptionPatch, self).__init__(**kwargs) + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The path ID that uniquely identifies the subscription of the edge profile. + :paramtype id: str + """ + super().__init__(**kwargs) self.id = id -class EtcdInfo(msrest.serialization.Model): +class EtcdInfo(_serialization.Model): """Etcd configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -1697,20 +1832,18 @@ class EtcdInfo(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(EtcdInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None @@ -1718,8 +1851,8 @@ def __init__( class Trigger(ARMBaseModel): """Trigger details. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FileEventTrigger, PeriodicTimerEventTrigger. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FileEventTrigger, PeriodicTimerEventTrigger Variables are only populated by the server, and will be ignored when sending a request. @@ -1733,38 +1866,33 @@ class Trigger(ARMBaseModel): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerEventType + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerEventType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'FileEvent': 'FileEventTrigger', 'PeriodicTimerEvent': 'PeriodicTimerEventTrigger'} - } + _subtype_map = {"kind": {"FileEvent": "FileEventTrigger", "PeriodicTimerEvent": "PeriodicTimerEventTrigger"}} - def __init__( - self, - **kwargs - ): - super(Trigger, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None - self.kind = 'Trigger' # type: str + self.kind: Optional[str] = None class FileEventTrigger(Trigger): @@ -1782,100 +1910,108 @@ class FileEventTrigger(Trigger): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerEventType - :param source_info: Required. File event source details. - :type source_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.FileSourceInfo - :param sink_info: Required. Role sink info. - :type sink_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerEventType + :ivar source_info: File event source details. Required. + :vartype source_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.FileSourceInfo + :ivar sink_info: Role sink info. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'FileSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "FileSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "FileSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.FileSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(FileEventTrigger, self).__init__(**kwargs) - self.kind = 'FileEvent' # type: str + """ + :keyword source_info: File event source details. Required. + :paramtype source_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.FileSourceInfo + :keyword sink_info: Role sink info. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "FileEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class FileSourceInfo(msrest.serialization.Model): +class FileSourceInfo(_serialization.Model): """File source details. All required parameters must be populated in order to send to Azure. - :param share_id: Required. File share ID. - :type share_id: str + :ivar share_id: File share ID. Required. + :vartype share_id: str """ _validation = { - 'share_id': {'required': True}, + "share_id": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, + "share_id": {"key": "shareId", "type": "str"}, } - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(FileSourceInfo, self).__init__(**kwargs) + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: File share ID. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id -class GenerateCertResponse(msrest.serialization.Model): +class GenerateCertResponse(_serialization.Model): """Used in activation key generation flow. - :param public_key: Gets or sets base64 encoded certificate raw data, + :ivar public_key: Gets or sets base64 encoded certificate raw data, this is the public part needed to be uploaded to cert vault. - :type public_key: str - :param private_key: Gets or sets base64 encoded private part of the certificate, + :vartype public_key: str + :ivar private_key: Gets or sets base64 encoded private part of the certificate, needed to form the activation key. - :type private_key: str - :param expiry_time_in_utc: Gets or sets expiry time in UTC. - :type expiry_time_in_utc: str + :vartype private_key: str + :ivar expiry_time_in_utc: Gets or sets expiry time in UTC. + :vartype expiry_time_in_utc: str """ _attribute_map = { - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'private_key': {'key': 'privateKey', 'type': 'str'}, - 'expiry_time_in_utc': {'key': 'expiryTimeInUTC', 'type': 'str'}, + "public_key": {"key": "publicKey", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "expiry_time_in_utc": {"key": "expiryTimeInUTC", "type": "str"}, } def __init__( @@ -1886,34 +2022,44 @@ def __init__( expiry_time_in_utc: Optional[str] = None, **kwargs ): - super(GenerateCertResponse, self).__init__(**kwargs) + """ + :keyword public_key: Gets or sets base64 encoded certificate raw data, + this is the public part needed to be uploaded to cert vault. + :paramtype public_key: str + :keyword private_key: Gets or sets base64 encoded private part of the certificate, + needed to form the activation key. + :paramtype private_key: str + :keyword expiry_time_in_utc: Gets or sets expiry time in UTC. + :paramtype expiry_time_in_utc: str + """ + super().__init__(**kwargs) self.public_key = public_key self.private_key = private_key self.expiry_time_in_utc = expiry_time_in_utc -class ImageRepositoryCredential(msrest.serialization.Model): +class ImageRepositoryCredential(_serialization.Model): """Image repository credential. All required parameters must be populated in order to send to Azure. - :param image_repository_url: Required. Image repository url (e.g.: mcr.microsoft.com). - :type image_repository_url: str - :param user_name: Required. Repository user name. - :type user_name: str - :param password: Repository user password. - :type password: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret + :ivar image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :vartype image_repository_url: str + :ivar user_name: Repository user name. Required. + :vartype user_name: str + :ivar password: Repository user password. + :vartype password: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret """ _validation = { - 'image_repository_url': {'required': True}, - 'user_name': {'required': True}, + "image_repository_url": {"required": True}, + "user_name": {"required": True}, } _attribute_map = { - 'image_repository_url': {'key': 'imageRepositoryUrl', 'type': 'str'}, - 'user_name': {'key': 'userName', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'AsymmetricEncryptedSecret'}, + "image_repository_url": {"key": "imageRepositoryUrl", "type": "str"}, + "user_name": {"key": "userName", "type": "str"}, + "password": {"key": "password", "type": "AsymmetricEncryptedSecret"}, } def __init__( @@ -1921,16 +2067,25 @@ def __init__( *, image_repository_url: str, user_name: str, - password: Optional["AsymmetricEncryptedSecret"] = None, + password: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs ): - super(ImageRepositoryCredential, self).__init__(**kwargs) + """ + :keyword image_repository_url: Image repository url (e.g.: mcr.microsoft.com). Required. + :paramtype image_repository_url: str + :keyword user_name: Repository user name. Required. + :paramtype user_name: str + :keyword password: Repository user password. + :paramtype password: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.image_repository_url = image_repository_url self.user_name = user_name self.password = password -class IoTAddon(Addon): +class IoTAddon(Addon): # pylint: disable=too-many-instance-attributes """IoT Addon. Variables are only populated by the server, and will be ignored when sending a request. @@ -1943,70 +2098,79 @@ class IoTAddon(Addon): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Addon type.Constant filled by server. Possible values include: - "IotEdge", "ArcForKubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonType + :ivar kind: Addon type. Required. Known values are: "IotEdge" and "ArcForKubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonType :ivar system_data: Addon type. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param io_t_device_details: Required. IoT device metadata to which appliance needs to be - connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: Required. IoT edge device to which the IoT Addon needs to be - configured. - :type io_t_edge_device_details: + :ivar io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be configured. + Required. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo :ivar version: Version of IoT running on the appliance. :vartype version: str - :ivar host_platform: Host OS supported by the IoT addon. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the IoT addon. Known values are: "Windows" and "Linux". :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.HostPlatformType - :ivar provisioning_state: Addon Provisioning State. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar provisioning_state: Addon Provisioning State. Known values are: "Invalid", "Creating", + "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'io_t_device_details': {'required': True}, - 'io_t_edge_device_details': {'required': True}, - 'version': {'readonly': True}, - 'host_platform': {'readonly': True}, - 'host_platform_type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "io_t_device_details": {"required": True}, + "io_t_edge_device_details": {"required": True}, + "version": {"readonly": True}, + "host_platform": {"readonly": True}, + "host_platform_type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "version": {"key": "properties.version", "type": "str"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - io_t_device_details: "IoTDeviceInfo", - io_t_edge_device_details: "IoTDeviceInfo", + io_t_device_details: "_models.IoTDeviceInfo", + io_t_edge_device_details: "_models.IoTDeviceInfo", **kwargs ): - super(IoTAddon, self).__init__(**kwargs) - self.kind = 'IotEdge' # type: str + """ + :keyword io_t_device_details: IoT device metadata to which appliance needs to be connected. + Required. + :paramtype io_t_device_details: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT Addon needs to be + configured. Required. + :paramtype io_t_edge_device_details: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo + """ + super().__init__(**kwargs) + self.kind: str = "IotEdge" self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details self.version = None @@ -2015,31 +2179,31 @@ def __init__( self.provisioning_state = None -class IoTDeviceInfo(msrest.serialization.Model): +class IoTDeviceInfo(_serialization.Model): """Metadata of IoT device/IoT Edge device to be configured. All required parameters must be populated in order to send to Azure. - :param device_id: Required. ID of the IoT device/edge device. - :type device_id: str - :param io_t_host_hub: Required. Host name for the IoT hub associated to the device. - :type io_t_host_hub: str - :param io_t_host_hub_id: Id for the IoT hub associated to the device. - :type io_t_host_hub_id: str - :param authentication: Encrypted IoT device/IoT edge device connection string. - :type authentication: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Authentication + :ivar device_id: ID of the IoT device/edge device. Required. + :vartype device_id: str + :ivar io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :vartype io_t_host_hub: str + :ivar io_t_host_hub_id: Id for the IoT hub associated to the device. + :vartype io_t_host_hub_id: str + :ivar authentication: Encrypted IoT device/IoT edge device connection string. + :vartype authentication: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Authentication """ _validation = { - 'device_id': {'required': True}, - 'io_t_host_hub': {'required': True}, + "device_id": {"required": True}, + "io_t_host_hub": {"required": True}, } _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'io_t_host_hub': {'key': 'ioTHostHub', 'type': 'str'}, - 'io_t_host_hub_id': {'key': 'ioTHostHubId', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, + "device_id": {"key": "deviceId", "type": "str"}, + "io_t_host_hub": {"key": "ioTHostHub", "type": "str"}, + "io_t_host_hub_id": {"key": "ioTHostHubId", "type": "str"}, + "authentication": {"key": "authentication", "type": "Authentication"}, } def __init__( @@ -2048,39 +2212,49 @@ def __init__( device_id: str, io_t_host_hub: str, io_t_host_hub_id: Optional[str] = None, - authentication: Optional["Authentication"] = None, + authentication: Optional["_models.Authentication"] = None, **kwargs ): - super(IoTDeviceInfo, self).__init__(**kwargs) + """ + :keyword device_id: ID of the IoT device/edge device. Required. + :paramtype device_id: str + :keyword io_t_host_hub: Host name for the IoT hub associated to the device. Required. + :paramtype io_t_host_hub: str + :keyword io_t_host_hub_id: Id for the IoT hub associated to the device. + :paramtype io_t_host_hub_id: str + :keyword authentication: Encrypted IoT device/IoT edge device connection string. + :paramtype authentication: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Authentication + """ + super().__init__(**kwargs) self.device_id = device_id self.io_t_host_hub = io_t_host_hub self.io_t_host_hub_id = io_t_host_hub_id self.authentication = authentication -class IoTEdgeAgentInfo(msrest.serialization.Model): +class IoTEdgeAgentInfo(_serialization.Model): """IoT edge agent details is optional, this will be used for download system Agent module while bootstrapping IoT Role if specified. All required parameters must be populated in order to send to Azure. - :param image_name: Required. Name of the IoT edge agent image. - :type image_name: str - :param tag: Required. Image Tag. - :type tag: str - :param image_repository: Image repository details. - :type image_repository: + :ivar image_name: Name of the IoT edge agent image. Required. + :vartype image_name: str + :ivar tag: Image Tag. Required. + :vartype tag: str + :ivar image_repository: Image repository details. + :vartype image_repository: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ImageRepositoryCredential """ _validation = { - 'image_name': {'required': True}, - 'tag': {'required': True}, + "image_name": {"required": True}, + "tag": {"required": True}, } _attribute_map = { - 'image_name': {'key': 'imageName', 'type': 'str'}, - 'tag': {'key': 'tag', 'type': 'str'}, - 'image_repository': {'key': 'imageRepository', 'type': 'ImageRepositoryCredential'}, + "image_name": {"key": "imageName", "type": "str"}, + "tag": {"key": "tag", "type": "str"}, + "image_repository": {"key": "imageRepository", "type": "ImageRepositoryCredential"}, } def __init__( @@ -2088,16 +2262,25 @@ def __init__( *, image_name: str, tag: str, - image_repository: Optional["ImageRepositoryCredential"] = None, + image_repository: Optional["_models.ImageRepositoryCredential"] = None, **kwargs ): - super(IoTEdgeAgentInfo, self).__init__(**kwargs) + """ + :keyword image_name: Name of the IoT edge agent image. Required. + :paramtype image_name: str + :keyword tag: Image Tag. Required. + :paramtype tag: str + :keyword image_repository: Image repository details. + :paramtype image_repository: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ImageRepositoryCredential + """ + super().__init__(**kwargs) self.image_name = image_name self.tag = tag self.image_repository = image_repository -class IoTRole(Role): +class IoTRole(Role): # pylint: disable=too-many-instance-attributes """Compute role. Variables are only populated by the server, and will be ignored when sending a request. @@ -2110,74 +2293,100 @@ class IoTRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param host_platform: Host OS supported by the IoT role. Possible values include: "Windows", + :ivar host_platform: Host OS supported by the IoT role. Known values are: "Windows" and "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType - :param io_t_device_details: IoT device metadata to which data box edge device needs to be + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType + :ivar io_t_device_details: IoT device metadata to which data box edge device needs to be connected. - :type io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo - :param io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. - :type io_t_edge_device_details: + :vartype io_t_device_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo + :ivar io_t_edge_device_details: IoT edge device to which the IoT role needs to be configured. + :vartype io_t_edge_device_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo - :param share_mappings: Mount points of shares in role(s). - :type share_mappings: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] - :param io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + :ivar share_mappings: Mount points of shares in role(s). + :vartype share_mappings: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] + :ivar io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot runtime. - :type io_t_edge_agent_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTEdgeAgentInfo - :ivar host_platform_type: Platform where the Iot runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :vartype io_t_edge_agent_info: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTEdgeAgentInfo + :ivar host_platform_type: Platform where the Iot runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.HostPlatformType - :param compute_resource: Resource allocation. - :type compute_resource: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ComputeResource - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus + :ivar compute_resource: Resource allocation. + :vartype compute_resource: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ComputeResource + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'host_platform_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "host_platform_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'io_t_device_details': {'key': 'properties.ioTDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'io_t_edge_device_details': {'key': 'properties.ioTEdgeDeviceDetails', 'type': 'IoTDeviceInfo'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'io_t_edge_agent_info': {'key': 'properties.ioTEdgeAgentInfo', 'type': 'IoTEdgeAgentInfo'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'compute_resource': {'key': 'properties.computeResource', 'type': 'ComputeResource'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "io_t_device_details": {"key": "properties.ioTDeviceDetails", "type": "IoTDeviceInfo"}, + "io_t_edge_device_details": {"key": "properties.ioTEdgeDeviceDetails", "type": "IoTDeviceInfo"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "io_t_edge_agent_info": {"key": "properties.ioTEdgeAgentInfo", "type": "IoTEdgeAgentInfo"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "compute_resource": {"key": "properties.computeResource", "type": "ComputeResource"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - io_t_device_details: Optional["IoTDeviceInfo"] = None, - io_t_edge_device_details: Optional["IoTDeviceInfo"] = None, - share_mappings: Optional[List["MountPointMap"]] = None, - io_t_edge_agent_info: Optional["IoTEdgeAgentInfo"] = None, - compute_resource: Optional["ComputeResource"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + io_t_device_details: Optional["_models.IoTDeviceInfo"] = None, + io_t_edge_device_details: Optional["_models.IoTDeviceInfo"] = None, + share_mappings: Optional[List["_models.MountPointMap"]] = None, + io_t_edge_agent_info: Optional["_models.IoTEdgeAgentInfo"] = None, + compute_resource: Optional["_models.ComputeResource"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(IoTRole, self).__init__(**kwargs) - self.kind = 'IOT' # type: str + """ + :keyword host_platform: Host OS supported by the IoT role. Known values are: "Windows" and + "Linux". + :paramtype host_platform: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType + :keyword io_t_device_details: IoT device metadata to which data box edge device needs to be + connected. + :paramtype io_t_device_details: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo + :keyword io_t_edge_device_details: IoT edge device to which the IoT role needs to be + configured. + :paramtype io_t_edge_device_details: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTDeviceInfo + :keyword share_mappings: Mount points of shares in role(s). + :paramtype share_mappings: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] + :keyword io_t_edge_agent_info: Iot edge agent details to download the agent and bootstrap iot + runtime. + :paramtype io_t_edge_agent_info: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.IoTEdgeAgentInfo + :keyword compute_resource: Resource allocation. + :paramtype compute_resource: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ComputeResource + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "IOT" self.host_platform = host_platform self.io_t_device_details = io_t_device_details self.io_t_edge_device_details = io_t_edge_device_details @@ -2188,7 +2397,7 @@ def __init__( self.role_status = role_status -class Ipv4Config(msrest.serialization.Model): +class Ipv4Config(_serialization.Model): """Details related to the IPv4 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2202,28 +2411,26 @@ class Ipv4Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'subnet': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "subnet": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv4Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.subnet = None self.gateway = None -class Ipv6Config(msrest.serialization.Model): +class Ipv6Config(_serialization.Model): """Details related to the IPv6 address configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2237,28 +2444,26 @@ class Ipv6Config(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, - 'prefix_length': {'readonly': True}, - 'gateway': {'readonly': True}, + "ip_address": {"readonly": True}, + "prefix_length": {"readonly": True}, + "gateway": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'prefix_length': {'key': 'prefixLength', 'type': 'int'}, - 'gateway': {'key': 'gateway', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "int"}, + "gateway": {"key": "gateway", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Ipv6Config, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None self.prefix_length = None self.gateway = None -class Job(msrest.serialization.Model): +class Job(_serialization.Model): # pylint: disable=too-many-instance-attributes """A device job. Variables are only populated by the server, and will be ignored when sending a request. @@ -2269,8 +2474,8 @@ class Job(msrest.serialization.Model): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :ivar status: The current status of the job. Possible values include: "Invalid", "Running", - "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar status: The current status of the job. Known values are: "Invalid", "Running", + "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobStatus :ivar start_time: The UTC date and time at which the job started. :vartype start_time: ~datetime.datetime @@ -2280,14 +2485,14 @@ class Job(msrest.serialization.Model): :vartype percent_complete: int :ivar error: The error details. :vartype error: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobErrorDetails - :ivar job_type: The type of the job. Possible values include: "Invalid", "ScanForUpdates", + :ivar job_type: The type of the job. Known values are: "Invalid", "ScanForUpdates", "DownloadUpdates", "InstallUpdates", "RefreshShare", "RefreshContainer", "Backup", "Restore", - "TriggerSupportPackage". + and "TriggerSupportPackage". :vartype job_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobType - :ivar current_stage: Current stage of the update operation. Possible values include: "Unknown", + :ivar current_stage: Current stage of the update operation. Known values are: "Unknown", "Initial", "ScanStarted", "ScanComplete", "ScanFailed", "DownloadStarted", "DownloadComplete", "DownloadFailed", "InstallStarted", "InstallComplete", "InstallFailed", "RebootInitiated", - "Success", "Failure", "RescanStarted", "RescanComplete", "RescanFailed". + "Success", "Failure", "RescanStarted", "RescanComplete", and "RescanFailed". :vartype current_stage: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateOperationStage :ivar download_progress: The download progress. @@ -2303,55 +2508,55 @@ class Job(msrest.serialization.Model): :vartype error_manifest_file: str :ivar refreshed_entity_id: ARM ID of the entity that was refreshed. :vartype refreshed_entity_id: str - :param folder: If only subfolders need to be refreshed, then the subfolder path inside the - share or container. (The path is empty if there are no subfolders.). - :type folder: str + :ivar folder: If only subfolders need to be refreshed, then the subfolder path inside the share + or container. (The path is empty if there are no subfolders.). + :vartype folder: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'error': {'readonly': True}, - 'job_type': {'readonly': True}, - 'current_stage': {'readonly': True}, - 'download_progress': {'readonly': True}, - 'install_progress': {'readonly': True}, - 'total_refresh_errors': {'readonly': True}, - 'error_manifest_file': {'readonly': True}, - 'refreshed_entity_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "error": {"readonly": True}, + "job_type": {"readonly": True}, + "current_stage": {"readonly": True}, + "download_progress": {"readonly": True}, + "install_progress": {"readonly": True}, + "total_refresh_errors": {"readonly": True}, + "error_manifest_file": {"readonly": True}, + "refreshed_entity_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'JobErrorDetails'}, - 'job_type': {'key': 'properties.jobType', 'type': 'str'}, - 'current_stage': {'key': 'properties.currentStage', 'type': 'str'}, - 'download_progress': {'key': 'properties.downloadProgress', 'type': 'UpdateDownloadProgress'}, - 'install_progress': {'key': 'properties.installProgress', 'type': 'UpdateInstallProgress'}, - 'total_refresh_errors': {'key': 'properties.totalRefreshErrors', 'type': 'int'}, - 'error_manifest_file': {'key': 'properties.errorManifestFile', 'type': 'str'}, - 'refreshed_entity_id': {'key': 'properties.refreshedEntityId', 'type': 'str'}, - 'folder': {'key': 'properties.folder', 'type': 'str'}, - } - - def __init__( - self, - *, - folder: Optional[str] = None, - **kwargs - ): - super(Job, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "error": {"key": "error", "type": "JobErrorDetails"}, + "job_type": {"key": "properties.jobType", "type": "str"}, + "current_stage": {"key": "properties.currentStage", "type": "str"}, + "download_progress": {"key": "properties.downloadProgress", "type": "UpdateDownloadProgress"}, + "install_progress": {"key": "properties.installProgress", "type": "UpdateInstallProgress"}, + "total_refresh_errors": {"key": "properties.totalRefreshErrors", "type": "int"}, + "error_manifest_file": {"key": "properties.errorManifestFile", "type": "str"}, + "refreshed_entity_id": {"key": "properties.refreshedEntityId", "type": "str"}, + "folder": {"key": "properties.folder", "type": "str"}, + } + + def __init__(self, *, folder: Optional[str] = None, **kwargs): + """ + :keyword folder: If only subfolders need to be refreshed, then the subfolder path inside the + share or container. (The path is empty if there are no subfolders.). + :paramtype folder: str + """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2370,7 +2575,7 @@ def __init__( self.folder = folder -class JobErrorDetails(msrest.serialization.Model): +class JobErrorDetails(_serialization.Model): """The job error information containing the list of job errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -2384,28 +2589,26 @@ class JobErrorDetails(msrest.serialization.Model): """ _validation = { - 'error_details': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "error_details": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'error_details': {'key': 'errorDetails', 'type': '[JobErrorItem]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "error_details": {"key": "errorDetails", "type": "[JobErrorItem]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error_details = None self.code = None self.message = None -class JobErrorItem(msrest.serialization.Model): +class JobErrorItem(_serialization.Model): """The job error items. Variables are only populated by the server, and will be ignored when sending a request. @@ -2419,28 +2622,26 @@ class JobErrorItem(msrest.serialization.Model): """ _validation = { - 'recommendations': {'readonly': True}, - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "recommendations": {"readonly": True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'recommendations': {'key': 'recommendations', 'type': '[str]'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "recommendations": {"key": "recommendations", "type": "[str]"}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(JobErrorItem, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.recommendations = None self.code = None self.message = None -class KubernetesClusterInfo(msrest.serialization.Model): +class KubernetesClusterInfo(_serialization.Model): """Kubernetes cluster configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2451,66 +2652,64 @@ class KubernetesClusterInfo(msrest.serialization.Model): :vartype etcd_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.EtcdInfo :ivar nodes: Kubernetes cluster nodes. :vartype nodes: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.NodeInfo] - :param version: Required. Kubernetes cluster version. - :type version: str + :ivar version: Kubernetes cluster version. Required. + :vartype version: str """ _validation = { - 'etcd_info': {'readonly': True}, - 'nodes': {'readonly': True}, - 'version': {'required': True}, + "etcd_info": {"readonly": True}, + "nodes": {"readonly": True}, + "version": {"required": True}, } _attribute_map = { - 'etcd_info': {'key': 'etcdInfo', 'type': 'EtcdInfo'}, - 'nodes': {'key': 'nodes', 'type': '[NodeInfo]'}, - 'version': {'key': 'version', 'type': 'str'}, + "etcd_info": {"key": "etcdInfo", "type": "EtcdInfo"}, + "nodes": {"key": "nodes", "type": "[NodeInfo]"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - *, - version: str, - **kwargs - ): - super(KubernetesClusterInfo, self).__init__(**kwargs) + def __init__(self, *, version: str, **kwargs): + """ + :keyword version: Kubernetes cluster version. Required. + :paramtype version: str + """ + super().__init__(**kwargs) self.etcd_info = None self.nodes = None self.version = version -class KubernetesIPConfiguration(msrest.serialization.Model): +class KubernetesIPConfiguration(_serialization.Model): """Kubernetes node IP configuration. Variables are only populated by the server, and will be ignored when sending a request. :ivar port: Port of the Kubernetes node. :vartype port: str - :param ip_address: IP address of the Kubernetes node. - :type ip_address: str + :ivar ip_address: IP address of the Kubernetes node. + :vartype ip_address: str """ _validation = { - 'port': {'readonly': True}, + "port": {"readonly": True}, } _attribute_map = { - 'port': {'key': 'port', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + "port": {"key": "port", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, } - def __init__( - self, - *, - ip_address: Optional[str] = None, - **kwargs - ): - super(KubernetesIPConfiguration, self).__init__(**kwargs) + def __init__(self, *, ip_address: Optional[str] = None, **kwargs): + """ + :keyword ip_address: IP address of the Kubernetes node. + :paramtype ip_address: str + """ + super().__init__(**kwargs) self.port = None self.ip_address = ip_address -class KubernetesRole(Role): +class KubernetesRole(Role): # pylint: disable=too-many-instance-attributes """Kubernetes role. Variables are only populated by the server, and will be ignored when sending a request. @@ -2523,67 +2722,81 @@ class KubernetesRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param host_platform: Host OS supported by the Kubernetes role. Possible values include: - "Windows", "Linux". - :type host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType - :ivar provisioning_state: State of Kubernetes deployment. Possible values include: "Invalid", - "Creating", "Created", "Updating", "Reconfiguring", "Failed", "Deleting". + :ivar host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" and + "Linux". + :vartype host_platform: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType + :ivar provisioning_state: State of Kubernetes deployment. Known values are: "Invalid", + "Creating", "Created", "Updating", "Reconfiguring", "Failed", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesState - :ivar host_platform_type: Platform where the runtime is hosted. Possible values include: - "KubernetesCluster", "LinuxVM". + :ivar host_platform_type: Platform where the runtime is hosted. Known values are: + "KubernetesCluster" and "LinuxVM". :vartype host_platform_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.HostPlatformType - :param kubernetes_cluster_info: Kubernetes cluster configuration. - :type kubernetes_cluster_info: + :ivar kubernetes_cluster_info: Kubernetes cluster configuration. + :vartype kubernetes_cluster_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesClusterInfo - :param kubernetes_role_resources: Kubernetes role resources. - :type kubernetes_role_resources: + :ivar kubernetes_role_resources: Kubernetes role resources. + :vartype kubernetes_role_resources: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleResources - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'host_platform_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "host_platform_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'host_platform': {'key': 'properties.hostPlatform', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'host_platform_type': {'key': 'properties.hostPlatformType', 'type': 'str'}, - 'kubernetes_cluster_info': {'key': 'properties.kubernetesClusterInfo', 'type': 'KubernetesClusterInfo'}, - 'kubernetes_role_resources': {'key': 'properties.kubernetesRoleResources', 'type': 'KubernetesRoleResources'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "host_platform": {"key": "properties.hostPlatform", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "host_platform_type": {"key": "properties.hostPlatformType", "type": "str"}, + "kubernetes_cluster_info": {"key": "properties.kubernetesClusterInfo", "type": "KubernetesClusterInfo"}, + "kubernetes_role_resources": {"key": "properties.kubernetesRoleResources", "type": "KubernetesRoleResources"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - host_platform: Optional[Union[str, "PlatformType"]] = None, - kubernetes_cluster_info: Optional["KubernetesClusterInfo"] = None, - kubernetes_role_resources: Optional["KubernetesRoleResources"] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + host_platform: Optional[Union[str, "_models.PlatformType"]] = None, + kubernetes_cluster_info: Optional["_models.KubernetesClusterInfo"] = None, + kubernetes_role_resources: Optional["_models.KubernetesRoleResources"] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(KubernetesRole, self).__init__(**kwargs) - self.kind = 'Kubernetes' # type: str + """ + :keyword host_platform: Host OS supported by the Kubernetes role. Known values are: "Windows" + and "Linux". + :paramtype host_platform: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PlatformType + :keyword kubernetes_cluster_info: Kubernetes cluster configuration. + :paramtype kubernetes_cluster_info: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesClusterInfo + :keyword kubernetes_role_resources: Kubernetes role resources. + :paramtype kubernetes_role_resources: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleResources + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "Kubernetes" self.host_platform = host_platform self.provisioning_state = None self.host_platform_type = None @@ -2592,46 +2805,45 @@ def __init__( self.role_status = role_status -class KubernetesRoleCompute(msrest.serialization.Model): +class KubernetesRoleCompute(_serialization.Model): """Kubernetes role compute resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param vm_profile: Required. VM profile. - :type vm_profile: str + :ivar vm_profile: VM profile. Required. + :vartype vm_profile: str :ivar memory_in_bytes: Memory in bytes. - :vartype memory_in_bytes: long + :vartype memory_in_bytes: int :ivar processor_count: Processor count. :vartype processor_count: int """ _validation = { - 'vm_profile': {'required': True}, - 'memory_in_bytes': {'readonly': True}, - 'processor_count': {'readonly': True}, + "vm_profile": {"required": True}, + "memory_in_bytes": {"readonly": True}, + "processor_count": {"readonly": True}, } _attribute_map = { - 'vm_profile': {'key': 'vmProfile', 'type': 'str'}, - 'memory_in_bytes': {'key': 'memoryInBytes', 'type': 'long'}, - 'processor_count': {'key': 'processorCount', 'type': 'int'}, + "vm_profile": {"key": "vmProfile", "type": "str"}, + "memory_in_bytes": {"key": "memoryInBytes", "type": "int"}, + "processor_count": {"key": "processorCount", "type": "int"}, } - def __init__( - self, - *, - vm_profile: str, - **kwargs - ): - super(KubernetesRoleCompute, self).__init__(**kwargs) + def __init__(self, *, vm_profile: str, **kwargs): + """ + :keyword vm_profile: VM profile. Required. + :paramtype vm_profile: str + """ + super().__init__(**kwargs) self.vm_profile = vm_profile self.memory_in_bytes = None self.processor_count = None -class KubernetesRoleNetwork(msrest.serialization.Model): +class KubernetesRoleNetwork(_serialization.Model): """Kubernetes role network resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2644,64 +2856,68 @@ class KubernetesRoleNetwork(msrest.serialization.Model): """ _validation = { - 'cni_config': {'readonly': True}, - 'load_balancer_config': {'readonly': True}, + "cni_config": {"readonly": True}, + "load_balancer_config": {"readonly": True}, } _attribute_map = { - 'cni_config': {'key': 'cniConfig', 'type': 'CniConfig'}, - 'load_balancer_config': {'key': 'loadBalancerConfig', 'type': 'LoadBalancerConfig'}, + "cni_config": {"key": "cniConfig", "type": "CniConfig"}, + "load_balancer_config": {"key": "loadBalancerConfig", "type": "LoadBalancerConfig"}, } - def __init__( - self, - **kwargs - ): - super(KubernetesRoleNetwork, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.cni_config = None self.load_balancer_config = None -class KubernetesRoleResources(msrest.serialization.Model): +class KubernetesRoleResources(_serialization.Model): """Kubernetes role resources. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param storage: Kubernetes role storage resource. - :type storage: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleStorage - :param compute: Required. Kubernetes role compute resource. - :type compute: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleCompute + :ivar storage: Kubernetes role storage resource. + :vartype storage: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleStorage + :ivar compute: Kubernetes role compute resource. Required. + :vartype compute: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleCompute :ivar network: Kubernetes role network resource. :vartype network: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleNetwork """ _validation = { - 'compute': {'required': True}, - 'network': {'readonly': True}, + "compute": {"required": True}, + "network": {"readonly": True}, } _attribute_map = { - 'storage': {'key': 'storage', 'type': 'KubernetesRoleStorage'}, - 'compute': {'key': 'compute', 'type': 'KubernetesRoleCompute'}, - 'network': {'key': 'network', 'type': 'KubernetesRoleNetwork'}, + "storage": {"key": "storage", "type": "KubernetesRoleStorage"}, + "compute": {"key": "compute", "type": "KubernetesRoleCompute"}, + "network": {"key": "network", "type": "KubernetesRoleNetwork"}, } def __init__( self, *, - compute: "KubernetesRoleCompute", - storage: Optional["KubernetesRoleStorage"] = None, + compute: "_models.KubernetesRoleCompute", + storage: Optional["_models.KubernetesRoleStorage"] = None, **kwargs ): - super(KubernetesRoleResources, self).__init__(**kwargs) + """ + :keyword storage: Kubernetes role storage resource. + :paramtype storage: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleStorage + :keyword compute: Kubernetes role compute resource. Required. + :paramtype compute: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleCompute + """ + super().__init__(**kwargs) self.storage = storage self.compute = compute self.network = None -class KubernetesRoleStorage(msrest.serialization.Model): +class KubernetesRoleStorage(_serialization.Model): """Kubernetes role storage resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2709,31 +2925,30 @@ class KubernetesRoleStorage(msrest.serialization.Model): :ivar storage_classes: Kubernetes storage class info. :vartype storage_classes: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesRoleStorageClassInfo] - :param endpoints: Mount points of shares in role(s). - :type endpoints: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] + :ivar endpoints: Mount points of shares in role(s). + :vartype endpoints: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] """ _validation = { - 'storage_classes': {'readonly': True}, + "storage_classes": {"readonly": True}, } _attribute_map = { - 'storage_classes': {'key': 'storageClasses', 'type': '[KubernetesRoleStorageClassInfo]'}, - 'endpoints': {'key': 'endpoints', 'type': '[MountPointMap]'}, + "storage_classes": {"key": "storageClasses", "type": "[KubernetesRoleStorageClassInfo]"}, + "endpoints": {"key": "endpoints", "type": "[MountPointMap]"}, } - def __init__( - self, - *, - endpoints: Optional[List["MountPointMap"]] = None, - **kwargs - ): - super(KubernetesRoleStorage, self).__init__(**kwargs) + def __init__(self, *, endpoints: Optional[List["_models.MountPointMap"]] = None, **kwargs): + """ + :keyword endpoints: Mount points of shares in role(s). + :paramtype endpoints: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] + """ + super().__init__(**kwargs) self.storage_classes = None self.endpoints = endpoints -class KubernetesRoleStorageClassInfo(msrest.serialization.Model): +class KubernetesRoleStorageClassInfo(_serialization.Model): """Kubernetes storage class info. Variables are only populated by the server, and will be ignored when sending a request. @@ -2742,35 +2957,33 @@ class KubernetesRoleStorageClassInfo(msrest.serialization.Model): :vartype name: str :ivar type: Storage class type. :vartype type: str - :ivar posix_compliant: If provisioned storage is posix compliant. Possible values include: - "Invalid", "Enabled", "Disabled". + :ivar posix_compliant: If provisioned storage is posix compliant. Known values are: "Invalid", + "Enabled", and "Disabled". :vartype posix_compliant: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PosixComplianceStatus """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'posix_compliant': {'readonly': True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "posix_compliant": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'posix_compliant': {'key': 'posixCompliant', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "posix_compliant": {"key": "posixCompliant", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(KubernetesRoleStorageClassInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.type = None self.posix_compliant = None -class LoadBalancerConfig(msrest.serialization.Model): +class LoadBalancerConfig(_serialization.Model): """Load balancer configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2782,20 +2995,18 @@ class LoadBalancerConfig(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'version': {'readonly': True}, + "type": {"readonly": True}, + "version": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "version": {"key": "version", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(LoadBalancerConfig, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.version = None @@ -2813,129 +3024,153 @@ class MECRole(Role): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param kind: Required. Role type.Constant filled by server. Possible values include: "IOT", - "ASA", "Functions", "Cognitive", "MEC", "CloudEdgeManagement", "Kubernetes". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes + :ivar kind: Role type. Required. Known values are: "IOT", "ASA", "Functions", "Cognitive", + "MEC", "CloudEdgeManagement", and "Kubernetes". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes :ivar system_data: Role configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param connection_string: Activation key of the MEC. - :type connection_string: + :ivar connection_string: Activation key of the MEC. + :vartype connection_string: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - :param controller_endpoint: Controller Endpoint. - :type controller_endpoint: str - :param resource_unique_id: Unique Id of the Resource. - :type resource_unique_id: str - :param role_status: Role status. Possible values include: "Enabled", "Disabled". - :type role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus + :ivar controller_endpoint: Controller Endpoint. + :vartype controller_endpoint: str + :ivar resource_unique_id: Unique Id of the Resource. + :vartype resource_unique_id: str + :ivar role_status: Role status. Known values are: "Enabled" and "Disabled". + :vartype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'AsymmetricEncryptedSecret'}, - 'controller_endpoint': {'key': 'properties.controllerEndpoint', 'type': 'str'}, - 'resource_unique_id': {'key': 'properties.resourceUniqueId', 'type': 'str'}, - 'role_status': {'key': 'properties.roleStatus', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "connection_string": {"key": "properties.connectionString", "type": "AsymmetricEncryptedSecret"}, + "controller_endpoint": {"key": "properties.controllerEndpoint", "type": "str"}, + "resource_unique_id": {"key": "properties.resourceUniqueId", "type": "str"}, + "role_status": {"key": "properties.roleStatus", "type": "str"}, } def __init__( self, *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, + connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, controller_endpoint: Optional[str] = None, resource_unique_id: Optional[str] = None, - role_status: Optional[Union[str, "RoleStatus"]] = None, + role_status: Optional[Union[str, "_models.RoleStatus"]] = None, **kwargs ): - super(MECRole, self).__init__(**kwargs) - self.kind = 'MEC' # type: str + """ + :keyword connection_string: Activation key of the MEC. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret + :keyword controller_endpoint: Controller Endpoint. + :paramtype controller_endpoint: str + :keyword resource_unique_id: Unique Id of the Resource. + :paramtype resource_unique_id: str + :keyword role_status: Role status. Known values are: "Enabled" and "Disabled". + :paramtype role_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleStatus + """ + super().__init__(**kwargs) + self.kind: str = "MEC" self.connection_string = connection_string self.controller_endpoint = controller_endpoint self.resource_unique_id = resource_unique_id self.role_status = role_status -class MetricConfiguration(msrest.serialization.Model): +class MetricConfiguration(_serialization.Model): """Metric configuration. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. The Resource ID on which the metrics should be pushed. - :type resource_id: str - :param mdm_account: The MDM account to which the counters should be pushed. - :type mdm_account: str - :param metric_name_space: The MDM namespace to which the counters should be pushed. This is + :ivar resource_id: The Resource ID on which the metrics should be pushed. Required. + :vartype resource_id: str + :ivar mdm_account: The MDM account to which the counters should be pushed. + :vartype mdm_account: str + :ivar metric_name_space: The MDM namespace to which the counters should be pushed. This is required if MDMAccount is specified. - :type metric_name_space: str - :param counter_sets: Required. Host name for the IoT hub associated to the device. - :type counter_sets: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCounterSet] + :vartype metric_name_space: str + :ivar counter_sets: Host name for the IoT hub associated to the device. Required. + :vartype counter_sets: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCounterSet] """ _validation = { - 'resource_id': {'required': True}, - 'counter_sets': {'required': True}, + "resource_id": {"required": True}, + "counter_sets": {"required": True}, } _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'mdm_account': {'key': 'mdmAccount', 'type': 'str'}, - 'metric_name_space': {'key': 'metricNameSpace', 'type': 'str'}, - 'counter_sets': {'key': 'counterSets', 'type': '[MetricCounterSet]'}, + "resource_id": {"key": "resourceId", "type": "str"}, + "mdm_account": {"key": "mdmAccount", "type": "str"}, + "metric_name_space": {"key": "metricNameSpace", "type": "str"}, + "counter_sets": {"key": "counterSets", "type": "[MetricCounterSet]"}, } def __init__( self, *, resource_id: str, - counter_sets: List["MetricCounterSet"], + counter_sets: List["_models.MetricCounterSet"], mdm_account: Optional[str] = None, metric_name_space: Optional[str] = None, **kwargs ): - super(MetricConfiguration, self).__init__(**kwargs) + """ + :keyword resource_id: The Resource ID on which the metrics should be pushed. Required. + :paramtype resource_id: str + :keyword mdm_account: The MDM account to which the counters should be pushed. + :paramtype mdm_account: str + :keyword metric_name_space: The MDM namespace to which the counters should be pushed. This is + required if MDMAccount is specified. + :paramtype metric_name_space: str + :keyword counter_sets: Host name for the IoT hub associated to the device. Required. + :paramtype counter_sets: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCounterSet] + """ + super().__init__(**kwargs) self.resource_id = resource_id self.mdm_account = mdm_account self.metric_name_space = metric_name_space self.counter_sets = counter_sets -class MetricCounter(msrest.serialization.Model): +class MetricCounter(_serialization.Model): """The metric counter. All required parameters must be populated in order to send to Azure. - :param name: Required. The counter name. - :type name: str - :param instance: The instance from which counter should be collected. - :type instance: str - :param dimension_filter: The dimension filter. - :type dimension_filter: + :ivar name: The counter name. Required. + :vartype name: str + :ivar instance: The instance from which counter should be collected. + :vartype instance: str + :ivar dimension_filter: The dimension filter. + :vartype dimension_filter: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimension] - :param additional_dimensions: The additional dimensions to be added to metric. - :type additional_dimensions: + :ivar additional_dimensions: The additional dimensions to be added to metric. + :vartype additional_dimensions: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimension] """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, - 'dimension_filter': {'key': 'dimensionFilter', 'type': '[MetricDimension]'}, - 'additional_dimensions': {'key': 'additionalDimensions', 'type': '[MetricDimension]'}, + "name": {"key": "name", "type": "str"}, + "instance": {"key": "instance", "type": "str"}, + "dimension_filter": {"key": "dimensionFilter", "type": "[MetricDimension]"}, + "additional_dimensions": {"key": "additionalDimensions", "type": "[MetricDimension]"}, } def __init__( @@ -2943,92 +3178,103 @@ def __init__( *, name: str, instance: Optional[str] = None, - dimension_filter: Optional[List["MetricDimension"]] = None, - additional_dimensions: Optional[List["MetricDimension"]] = None, + dimension_filter: Optional[List["_models.MetricDimension"]] = None, + additional_dimensions: Optional[List["_models.MetricDimension"]] = None, **kwargs ): - super(MetricCounter, self).__init__(**kwargs) + """ + :keyword name: The counter name. Required. + :paramtype name: str + :keyword instance: The instance from which counter should be collected. + :paramtype instance: str + :keyword dimension_filter: The dimension filter. + :paramtype dimension_filter: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimension] + :keyword additional_dimensions: The additional dimensions to be added to metric. + :paramtype additional_dimensions: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimension] + """ + super().__init__(**kwargs) self.name = name self.instance = instance self.dimension_filter = dimension_filter self.additional_dimensions = additional_dimensions -class MetricCounterSet(msrest.serialization.Model): +class MetricCounterSet(_serialization.Model): """The metric counter set. All required parameters must be populated in order to send to Azure. - :param counters: Required. The counters that should be collected in this set. - :type counters: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCounter] + :ivar counters: The counters that should be collected in this set. Required. + :vartype counters: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCounter] """ _validation = { - 'counters': {'required': True}, + "counters": {"required": True}, } _attribute_map = { - 'counters': {'key': 'counters', 'type': '[MetricCounter]'}, + "counters": {"key": "counters", "type": "[MetricCounter]"}, } - def __init__( - self, - *, - counters: List["MetricCounter"], - **kwargs - ): - super(MetricCounterSet, self).__init__(**kwargs) + def __init__(self, *, counters: List["_models.MetricCounter"], **kwargs): + """ + :keyword counters: The counters that should be collected in this set. Required. + :paramtype counters: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCounter] + """ + super().__init__(**kwargs) self.counters = counters -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """The metric dimension. All required parameters must be populated in order to send to Azure. - :param source_type: Required. The dimension type. - :type source_type: str - :param source_name: Required. The dimension value. - :type source_name: str + :ivar source_type: The dimension type. Required. + :vartype source_type: str + :ivar source_name: The dimension value. Required. + :vartype source_name: str """ _validation = { - 'source_type': {'required': True}, - 'source_name': {'required': True}, + "source_type": {"required": True}, + "source_name": {"required": True}, } _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'source_name': {'key': 'sourceName', 'type': 'str'}, - } - - def __init__( - self, - *, - source_type: str, - source_name: str, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) + "source_type": {"key": "sourceType", "type": "str"}, + "source_name": {"key": "sourceName", "type": "str"}, + } + + def __init__(self, *, source_type: str, source_name: str, **kwargs): + """ + :keyword source_type: The dimension type. Required. + :paramtype source_type: str + :keyword source_name: The dimension value. Required. + :paramtype source_name: str + """ + super().__init__(**kwargs) self.source_type = source_type self.source_name = source_name -class MetricDimensionV1(msrest.serialization.Model): +class MetricDimensionV1(_serialization.Model): """Metric Dimension v1. - :param name: Name of the metrics dimension. - :type name: str - :param display_name: Display name of the metrics dimension. - :type display_name: str - :param to_be_exported_for_shoebox: To be exported to shoe box. - :type to_be_exported_for_shoebox: bool + :ivar name: Name of the metrics dimension. + :vartype name: str + :ivar display_name: Display name of the metrics dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: To be exported to shoe box. + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -3039,56 +3285,64 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(MetricDimensionV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metrics dimension. + :paramtype name: str + :keyword display_name: Display name of the metrics dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: To be exported to shoe box. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecificationV1(msrest.serialization.Model): +class MetricSpecificationV1(_serialization.Model): # pylint: disable=too-many-instance-attributes """Metric specification version 1. - :param name: Name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Description of the metric to be displayed. - :type display_description: str - :param unit: Metric units. Possible values include: "NotSpecified", "Percent", "Count", - "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond". - :type unit: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricUnit - :param aggregation_type: Metric aggregation type. Possible values include: "NotSpecified", - "None", "Average", "Minimum", "Maximum", "Total", "Count". - :type aggregation_type: str or + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Description of the metric to be displayed. + :vartype display_description: str + :ivar unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :vartype unit: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricUnit + :ivar aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :vartype aggregation_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricAggregationType - :param dimensions: Metric dimensions, other than default dimension which is resource. - :type dimensions: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimensionV1] - :param fill_gap_with_zero: Set true to fill the gaps with zero. - :type fill_gap_with_zero: bool - :param category: Metric category. Possible values include: "Capacity", "Transaction". - :type category: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCategory - :param resource_id_dimension_name_override: Resource name override. - :type resource_id_dimension_name_override: str - :param supported_time_grain_types: Support granularity of metrics. - :type supported_time_grain_types: list[str or + :ivar dimensions: Metric dimensions, other than default dimension which is resource. + :vartype dimensions: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimensionV1] + :ivar fill_gap_with_zero: Set true to fill the gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar category: Metric category. Known values are: "Capacity" and "Transaction". + :vartype category: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCategory + :ivar resource_id_dimension_name_override: Resource name override. + :vartype resource_id_dimension_name_override: str + :ivar supported_time_grain_types: Support granularity of metrics. + :vartype supported_time_grain_types: list[str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TimeGrain] - :param supported_aggregation_types: Support metric aggregation type. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: Support metric aggregation type. + :vartype supported_aggregation_types: list[str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricAggregationType] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimensionV1]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimensionV1]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, } def __init__( @@ -3097,17 +3351,47 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, display_description: Optional[str] = None, - unit: Optional[Union[str, "MetricUnit"]] = None, - aggregation_type: Optional[Union[str, "MetricAggregationType"]] = None, - dimensions: Optional[List["MetricDimensionV1"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + aggregation_type: Optional[Union[str, "_models.MetricAggregationType"]] = None, + dimensions: Optional[List["_models.MetricDimensionV1"]] = None, fill_gap_with_zero: Optional[bool] = None, - category: Optional[Union[str, "MetricCategory"]] = None, + category: Optional[Union[str, "_models.MetricCategory"]] = None, resource_id_dimension_name_override: Optional[str] = None, - supported_time_grain_types: Optional[List[Union[str, "TimeGrain"]]] = None, - supported_aggregation_types: Optional[List[Union[str, "MetricAggregationType"]]] = None, + supported_time_grain_types: Optional[List[Union[str, "_models.TimeGrain"]]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.MetricAggregationType"]]] = None, **kwargs ): - super(MetricSpecificationV1, self).__init__(**kwargs) + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Description of the metric to be displayed. + :paramtype display_description: str + :keyword unit: Metric units. Known values are: "NotSpecified", "Percent", "Count", "Seconds", + "Milliseconds", "Bytes", "BytesPerSecond", and "CountPerSecond". + :paramtype unit: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricUnit + :keyword aggregation_type: Metric aggregation type. Known values are: "NotSpecified", "None", + "Average", "Minimum", "Maximum", "Total", and "Count". + :paramtype aggregation_type: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricAggregationType + :keyword dimensions: Metric dimensions, other than default dimension which is resource. + :paramtype dimensions: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricDimensionV1] + :keyword fill_gap_with_zero: Set true to fill the gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: Metric category. Known values are: "Capacity" and "Transaction". + :paramtype category: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricCategory + :keyword resource_id_dimension_name_override: Resource name override. + :paramtype resource_id_dimension_name_override: str + :keyword supported_time_grain_types: Support granularity of metrics. + :paramtype supported_time_grain_types: list[str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TimeGrain] + :keyword supported_aggregation_types: Support metric aggregation type. + :paramtype supported_aggregation_types: list[str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricAggregationType] + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -3136,39 +3420,39 @@ class MonitoringMetricConfiguration(ARMBaseModel): :vartype type: str :ivar system_data: MonitoringConfiguration on ASE device. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param metric_configurations: Required. The metrics configuration details. - :type metric_configurations: + :ivar metric_configurations: The metrics configuration details. Required. + :vartype metric_configurations: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricConfiguration] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'metric_configurations': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "metric_configurations": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'metric_configurations': {'key': 'properties.metricConfigurations', 'type': '[MetricConfiguration]'}, - } - - def __init__( - self, - *, - metric_configurations: List["MetricConfiguration"], - **kwargs - ): - super(MonitoringMetricConfiguration, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "metric_configurations": {"key": "properties.metricConfigurations", "type": "[MetricConfiguration]"}, + } + + def __init__(self, *, metric_configurations: List["_models.MetricConfiguration"], **kwargs): + """ + :keyword metric_configurations: The metrics configuration details. Required. + :paramtype metric_configurations: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricConfiguration] + """ + super().__init__(**kwargs) self.system_data = None self.metric_configurations = metric_configurations -class MonitoringMetricConfigurationList(msrest.serialization.Model): +class MonitoringMetricConfigurationList(_serialization.Model): """Collection of metric configurations. Variables are only populated by the server, and will be ignored when sending a request. @@ -3181,67 +3465,64 @@ class MonitoringMetricConfigurationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MonitoringMetricConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MonitoringMetricConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(MonitoringMetricConfigurationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class MountPointMap(msrest.serialization.Model): +class MountPointMap(_serialization.Model): """The share mount point. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param share_id: Required. ID of the share mounted to the role VM. - :type share_id: str + :ivar share_id: ID of the share mounted to the role VM. Required. + :vartype share_id: str :ivar role_id: ID of the role to which share is mounted. :vartype role_id: str :ivar mount_point: Mount point for the share. :vartype mount_point: str - :ivar mount_type: Mounting type. Possible values include: "Volume", "HostPath". + :ivar mount_type: Mounting type. Known values are: "Volume" and "HostPath". :vartype mount_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountType - :ivar role_type: Role type. Possible values include: "IOT", "ASA", "Functions", "Cognitive", - "MEC", "CloudEdgeManagement", "Kubernetes". + :ivar role_type: Role type. Known values are: "IOT", "ASA", "Functions", "Cognitive", "MEC", + "CloudEdgeManagement", and "Kubernetes". :vartype role_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleTypes """ _validation = { - 'share_id': {'required': True}, - 'role_id': {'readonly': True}, - 'mount_point': {'readonly': True}, - 'mount_type': {'readonly': True}, - 'role_type': {'readonly': True}, + "share_id": {"required": True}, + "role_id": {"readonly": True}, + "mount_point": {"readonly": True}, + "mount_type": {"readonly": True}, + "role_type": {"readonly": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'mount_point': {'key': 'mountPoint', 'type': 'str'}, - 'mount_type': {'key': 'mountType', 'type': 'str'}, - 'role_type': {'key': 'roleType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - **kwargs - ): - super(MountPointMap, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "role_id": {"key": "roleId", "type": "str"}, + "mount_point": {"key": "mountPoint", "type": "str"}, + "mount_type": {"key": "mountType", "type": "str"}, + "role_type": {"key": "roleType", "type": "str"}, + } + + def __init__(self, *, share_id: str, **kwargs): + """ + :keyword share_id: ID of the share mounted to the role VM. Required. + :paramtype share_id: str + """ + super().__init__(**kwargs) self.share_id = share_id self.role_id = None self.mount_point = None @@ -3249,7 +3530,7 @@ def __init__( self.role_type = None -class NetworkAdapter(msrest.serialization.Model): +class NetworkAdapter(_serialization.Model): # pylint: disable=too-many-instance-attributes """Represents the networkAdapter on a device. Variables are only populated by the server, and will be ignored when sending a request. @@ -3270,17 +3551,17 @@ class NetworkAdapter(msrest.serialization.Model): :ivar mac_address: MAC address. :vartype mac_address: str :ivar link_speed: Link speed. - :vartype link_speed: long - :ivar status: Value indicating whether this adapter is valid. Possible values include: - "Inactive", "Active". + :vartype link_speed: int + :ivar status: Value indicating whether this adapter is valid. Known values are: "Inactive" and + "Active". :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapterStatus - :param rdma_status: Value indicating whether this adapter is RDMA capable. Possible values - include: "Incapable", "Capable". - :type rdma_status: str or + :ivar rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :vartype rdma_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapterRDMAStatus - :param dhcp_status: Value indicating whether this adapter has DHCP enabled. Possible values - include: "Disabled", "Enabled". - :type dhcp_status: str or + :ivar dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :vartype dhcp_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapterDHCPStatus :ivar ipv4_configuration: The IPv4 configuration of the network adapter. :vartype ipv4_configuration: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Ipv4Config @@ -3293,47 +3574,57 @@ class NetworkAdapter(msrest.serialization.Model): """ _validation = { - 'adapter_id': {'readonly': True}, - 'adapter_position': {'readonly': True}, - 'index': {'readonly': True}, - 'node_id': {'readonly': True}, - 'network_adapter_name': {'readonly': True}, - 'label': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'link_speed': {'readonly': True}, - 'status': {'readonly': True}, - 'ipv4_configuration': {'readonly': True}, - 'ipv6_configuration': {'readonly': True}, - 'ipv6_link_local_address': {'readonly': True}, - 'dns_servers': {'readonly': True}, + "adapter_id": {"readonly": True}, + "adapter_position": {"readonly": True}, + "index": {"readonly": True}, + "node_id": {"readonly": True}, + "network_adapter_name": {"readonly": True}, + "label": {"readonly": True}, + "mac_address": {"readonly": True}, + "link_speed": {"readonly": True}, + "status": {"readonly": True}, + "ipv4_configuration": {"readonly": True}, + "ipv6_configuration": {"readonly": True}, + "ipv6_link_local_address": {"readonly": True}, + "dns_servers": {"readonly": True}, } _attribute_map = { - 'adapter_id': {'key': 'adapterId', 'type': 'str'}, - 'adapter_position': {'key': 'adapterPosition', 'type': 'NetworkAdapterPosition'}, - 'index': {'key': 'index', 'type': 'int'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'network_adapter_name': {'key': 'networkAdapterName', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'link_speed': {'key': 'linkSpeed', 'type': 'long'}, - 'status': {'key': 'status', 'type': 'str'}, - 'rdma_status': {'key': 'rdmaStatus', 'type': 'str'}, - 'dhcp_status': {'key': 'dhcpStatus', 'type': 'str'}, - 'ipv4_configuration': {'key': 'ipv4Configuration', 'type': 'Ipv4Config'}, - 'ipv6_configuration': {'key': 'ipv6Configuration', 'type': 'Ipv6Config'}, - 'ipv6_link_local_address': {'key': 'ipv6LinkLocalAddress', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, + "adapter_id": {"key": "adapterId", "type": "str"}, + "adapter_position": {"key": "adapterPosition", "type": "NetworkAdapterPosition"}, + "index": {"key": "index", "type": "int"}, + "node_id": {"key": "nodeId", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "mac_address": {"key": "macAddress", "type": "str"}, + "link_speed": {"key": "linkSpeed", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "rdma_status": {"key": "rdmaStatus", "type": "str"}, + "dhcp_status": {"key": "dhcpStatus", "type": "str"}, + "ipv4_configuration": {"key": "ipv4Configuration", "type": "Ipv4Config"}, + "ipv6_configuration": {"key": "ipv6Configuration", "type": "Ipv6Config"}, + "ipv6_link_local_address": {"key": "ipv6LinkLocalAddress", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, } def __init__( self, *, - rdma_status: Optional[Union[str, "NetworkAdapterRDMAStatus"]] = None, - dhcp_status: Optional[Union[str, "NetworkAdapterDHCPStatus"]] = None, + rdma_status: Optional[Union[str, "_models.NetworkAdapterRDMAStatus"]] = None, + dhcp_status: Optional[Union[str, "_models.NetworkAdapterDHCPStatus"]] = None, **kwargs ): - super(NetworkAdapter, self).__init__(**kwargs) + """ + :keyword rdma_status: Value indicating whether this adapter is RDMA capable. Known values are: + "Incapable" and "Capable". + :paramtype rdma_status: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapterRDMAStatus + :keyword dhcp_status: Value indicating whether this adapter has DHCP enabled. Known values are: + "Disabled" and "Enabled". + :paramtype dhcp_status: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkAdapterDHCPStatus + """ + super().__init__(**kwargs) self.adapter_id = None self.adapter_position = None self.index = None @@ -3351,32 +3642,30 @@ def __init__( self.dns_servers = None -class NetworkAdapterPosition(msrest.serialization.Model): +class NetworkAdapterPosition(_serialization.Model): """The network adapter position. Variables are only populated by the server, and will be ignored when sending a request. - :ivar network_group: The network group. Possible values include: "None", "NonRDMA", "RDMA". + :ivar network_group: The network group. Known values are: "None", "NonRDMA", and "RDMA". :vartype network_group: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkGroup :ivar port: The port. :vartype port: int """ _validation = { - 'network_group': {'readonly': True}, - 'port': {'readonly': True}, + "network_group": {"readonly": True}, + "port": {"readonly": True}, } _attribute_map = { - 'network_group': {'key': 'networkGroup', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, + "network_group": {"key": "networkGroup", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(NetworkAdapterPosition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.network_group = None self.port = None @@ -3400,92 +3689,88 @@ class NetworkSettings(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'network_adapters': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "network_adapters": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'network_adapters': {'key': 'properties.networkAdapters', 'type': '[NetworkAdapter]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "network_adapters": {"key": "properties.networkAdapters", "type": "[NetworkAdapter]"}, } - def __init__( - self, - **kwargs - ): - super(NetworkSettings, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None self.network_adapters = None class Node(ARMBaseModel): """Represents a single node in a Data box Edge/Gateway device -Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node -Multi-node Edge devices will have more than 1 nodes. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The path ID that uniquely identifies the object. - :vartype id: str - :ivar name: The object name. - :vartype name: str - :ivar type: The hierarchical type of the object. - :vartype type: str - :ivar node_status: The current status of the individual node. Possible values include: - "Unknown", "Up", "Down", "Rebooting", "ShuttingDown". - :vartype node_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NodeStatus - :ivar node_chassis_serial_number: Serial number of the Chassis. - :vartype node_chassis_serial_number: str - :ivar node_serial_number: Serial number of the individual node. - :vartype node_serial_number: str - :ivar node_display_name: Display Name of the individual node. - :vartype node_display_name: str - :ivar node_friendly_software_version: Friendly software version name that is currently - installed on the node. - :vartype node_friendly_software_version: str - :ivar node_hcs_version: HCS version that is currently installed on the node. - :vartype node_hcs_version: str - :ivar node_instance_id: Guid instance id of the node. - :vartype node_instance_id: str + Gateway devices, standalone Edge devices and a single node cluster Edge device will all have 1 node + Multi-node Edge devices will have more than 1 nodes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The path ID that uniquely identifies the object. + :vartype id: str + :ivar name: The object name. + :vartype name: str + :ivar type: The hierarchical type of the object. + :vartype type: str + :ivar node_status: The current status of the individual node. Known values are: "Unknown", + "Up", "Down", "Rebooting", and "ShuttingDown". + :vartype node_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NodeStatus + :ivar node_chassis_serial_number: Serial number of the Chassis. + :vartype node_chassis_serial_number: str + :ivar node_serial_number: Serial number of the individual node. + :vartype node_serial_number: str + :ivar node_display_name: Display Name of the individual node. + :vartype node_display_name: str + :ivar node_friendly_software_version: Friendly software version name that is currently + installed on the node. + :vartype node_friendly_software_version: str + :ivar node_hcs_version: HCS version that is currently installed on the node. + :vartype node_hcs_version: str + :ivar node_instance_id: Guid instance id of the node. + :vartype node_instance_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'node_status': {'readonly': True}, - 'node_chassis_serial_number': {'readonly': True}, - 'node_serial_number': {'readonly': True}, - 'node_display_name': {'readonly': True}, - 'node_friendly_software_version': {'readonly': True}, - 'node_hcs_version': {'readonly': True}, - 'node_instance_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "node_status": {"readonly": True}, + "node_chassis_serial_number": {"readonly": True}, + "node_serial_number": {"readonly": True}, + "node_display_name": {"readonly": True}, + "node_friendly_software_version": {"readonly": True}, + "node_hcs_version": {"readonly": True}, + "node_instance_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'node_status': {'key': 'properties.nodeStatus', 'type': 'str'}, - 'node_chassis_serial_number': {'key': 'properties.nodeChassisSerialNumber', 'type': 'str'}, - 'node_serial_number': {'key': 'properties.nodeSerialNumber', 'type': 'str'}, - 'node_display_name': {'key': 'properties.nodeDisplayName', 'type': 'str'}, - 'node_friendly_software_version': {'key': 'properties.nodeFriendlySoftwareVersion', 'type': 'str'}, - 'node_hcs_version': {'key': 'properties.nodeHcsVersion', 'type': 'str'}, - 'node_instance_id': {'key': 'properties.nodeInstanceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Node, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "node_status": {"key": "properties.nodeStatus", "type": "str"}, + "node_chassis_serial_number": {"key": "properties.nodeChassisSerialNumber", "type": "str"}, + "node_serial_number": {"key": "properties.nodeSerialNumber", "type": "str"}, + "node_display_name": {"key": "properties.nodeDisplayName", "type": "str"}, + "node_friendly_software_version": {"key": "properties.nodeFriendlySoftwareVersion", "type": "str"}, + "node_hcs_version": {"key": "properties.nodeHcsVersion", "type": "str"}, + "node_instance_id": {"key": "properties.nodeInstanceId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.node_status = None self.node_chassis_serial_number = None self.node_serial_number = None @@ -3495,109 +3780,121 @@ def __init__( self.node_instance_id = None -class NodeInfo(msrest.serialization.Model): +class NodeInfo(_serialization.Model): """Kubernetes node info. Variables are only populated by the server, and will be ignored when sending a request. :ivar name: Node name. :vartype name: str - :ivar type: Node type - Master/Worker. Possible values include: "Invalid", "Master", "Worker". + :ivar type: Node type - Master/Worker. Known values are: "Invalid", "Master", and "Worker". :vartype type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesNodeType - :param ip_configuration: IP Configuration of the Kubernetes node. - :type ip_configuration: + :ivar ip_configuration: IP Configuration of the Kubernetes node. + :vartype ip_configuration: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesIPConfiguration] """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'ip_configuration': {'key': 'ipConfiguration', 'type': '[KubernetesIPConfiguration]'}, - } - - def __init__( - self, - *, - ip_configuration: Optional[List["KubernetesIPConfiguration"]] = None, - **kwargs - ): - super(NodeInfo, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "ip_configuration": {"key": "ipConfiguration", "type": "[KubernetesIPConfiguration]"}, + } + + def __init__(self, *, ip_configuration: Optional[List["_models.KubernetesIPConfiguration"]] = None, **kwargs): + """ + :keyword ip_configuration: IP Configuration of the Kubernetes node. + :paramtype ip_configuration: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.KubernetesIPConfiguration] + """ + super().__init__(**kwargs) self.name = None self.type = None self.ip_configuration = ip_configuration -class NodeList(msrest.serialization.Model): +class NodeList(_serialization.Model): """Collection of Nodes. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of Nodes. :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Node] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Node]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Node]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - next_link: Optional[str] = None, - **kwargs - ): - super(NodeList, self).__init__(**kwargs) + def __init__(self, *, next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = None self.next_link = next_link -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Operations. - :param name: Name of the operation. - :type name: str - :param display: Properties displayed for the operation. - :type display: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param service_specification: Service specification. - :type service_specification: + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties displayed for the operation. + :vartype display: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar service_specification: Service specification. + :vartype service_specification: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ServiceSpecification """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, is_data_action: Optional[bool] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): - super(Operation, self).__init__(**kwargs) + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties displayed for the operation. + :paramtype display: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword service_specification: Service specification. + :paramtype service_specification: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ServiceSpecification + """ + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin @@ -3605,24 +3902,24 @@ def __init__( self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display properties. - :param provider: Provider name. - :type provider: str - :param resource: The type of resource in which the operation is performed. - :type resource: str - :param operation: Operation to be performed on the resource. - :type operation: str - :param description: Description of the operation to be performed. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: The type of resource in which the operation is performed. + :vartype resource: str + :ivar operation: Operation to be performed on the resource. + :vartype operation: str + :ivar description: Description of the operation to be performed. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -3634,46 +3931,56 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: The type of resource in which the operation is performed. + :paramtype resource: str + :keyword operation: Operation to be performed on the resource. + :paramtype operation: str + :keyword description: Description of the operation to be performed. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsList(msrest.serialization.Model): +class OperationsList(_serialization.Model): """The list of operations used for the discovery of available provider operations. All required parameters must be populated in order to send to Azure. - :param value: Required. The value. - :type value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Operation] - :param next_link: Link to the next set of results. - :type next_link: str + :ivar value: The value. Required. + :vartype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Operation] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: List["Operation"], - next_link: Optional[str] = None, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The value. Required. + :paramtype value: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Operation] + :keyword next_link: Link to the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Order(ARMBaseModel): +class Order(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The order details. Variables are only populated by the server, and will be ignored when sending a request. @@ -3686,10 +3993,10 @@ class Order(ARMBaseModel): :vartype type: str :ivar system_data: Order configured on ASE resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param contact_information: The contact details. - :type contact_information: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ContactDetails - :param shipping_address: The shipping address. - :type shipping_address: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Address + :ivar contact_information: The contact details. + :vartype contact_information: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ContactDetails + :ivar shipping_address: The shipping address. + :vartype shipping_address: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Address :ivar current_status: Current status of the order. :vartype current_status: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OrderStatus :ivar order_history: List of status changes in the order. @@ -3704,47 +4011,58 @@ class Order(ARMBaseModel): whether it has an original or a replacement device. :vartype return_tracking_info: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.TrackingInfo] - :param shipment_type: ShipmentType of the order. Possible values include: "NotApplicable", - "ShippedToCustomer", "SelfPickup". - :type shipment_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShipmentType + :ivar shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :vartype shipment_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShipmentType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'current_status': {'readonly': True}, - 'order_history': {'readonly': True}, - 'serial_number': {'readonly': True}, - 'delivery_tracking_info': {'readonly': True}, - 'return_tracking_info': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "current_status": {"readonly": True}, + "order_history": {"readonly": True}, + "serial_number": {"readonly": True}, + "delivery_tracking_info": {"readonly": True}, + "return_tracking_info": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'contact_information': {'key': 'properties.contactInformation', 'type': 'ContactDetails'}, - 'shipping_address': {'key': 'properties.shippingAddress', 'type': 'Address'}, - 'current_status': {'key': 'properties.currentStatus', 'type': 'OrderStatus'}, - 'order_history': {'key': 'properties.orderHistory', 'type': '[OrderStatus]'}, - 'serial_number': {'key': 'properties.serialNumber', 'type': 'str'}, - 'delivery_tracking_info': {'key': 'properties.deliveryTrackingInfo', 'type': '[TrackingInfo]'}, - 'return_tracking_info': {'key': 'properties.returnTrackingInfo', 'type': '[TrackingInfo]'}, - 'shipment_type': {'key': 'properties.shipmentType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "contact_information": {"key": "properties.contactInformation", "type": "ContactDetails"}, + "shipping_address": {"key": "properties.shippingAddress", "type": "Address"}, + "current_status": {"key": "properties.currentStatus", "type": "OrderStatus"}, + "order_history": {"key": "properties.orderHistory", "type": "[OrderStatus]"}, + "serial_number": {"key": "properties.serialNumber", "type": "str"}, + "delivery_tracking_info": {"key": "properties.deliveryTrackingInfo", "type": "[TrackingInfo]"}, + "return_tracking_info": {"key": "properties.returnTrackingInfo", "type": "[TrackingInfo]"}, + "shipment_type": {"key": "properties.shipmentType", "type": "str"}, } def __init__( self, *, - contact_information: Optional["ContactDetails"] = None, - shipping_address: Optional["Address"] = None, - shipment_type: Optional[Union[str, "ShipmentType"]] = None, + contact_information: Optional["_models.ContactDetails"] = None, + shipping_address: Optional["_models.Address"] = None, + shipment_type: Optional[Union[str, "_models.ShipmentType"]] = None, **kwargs ): - super(Order, self).__init__(**kwargs) + """ + :keyword contact_information: The contact details. + :paramtype contact_information: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ContactDetails + :keyword shipping_address: The shipping address. + :paramtype shipping_address: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Address + :keyword shipment_type: ShipmentType of the order. Known values are: "NotApplicable", + "ShippedToCustomer", and "SelfPickup". + :paramtype shipment_type: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShipmentType + """ + super().__init__(**kwargs) self.system_data = None self.contact_information = contact_information self.shipping_address = shipping_address @@ -3756,7 +4074,7 @@ def __init__( self.shipment_type = shipment_type -class OrderList(msrest.serialization.Model): +class OrderList(_serialization.Model): """List of order entities. Variables are only populated by the server, and will be ignored when sending a request. @@ -3768,41 +4086,39 @@ class OrderList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Order]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Order]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(OrderList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OrderStatus(msrest.serialization.Model): +class OrderStatus(_serialization.Model): """Represents a single status change. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param status: Required. Status of the order as per the allowed status types. Possible values - include: "Untracked", "AwaitingFulfillment", "AwaitingPreparation", "AwaitingShipment", - "Shipped", "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", - "ReturnInitiated", "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", - "AwaitingPickup", "PickupCompleted", "AwaitingDrop". - :type status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OrderState + :ivar status: Status of the order as per the allowed status types. Required. Known values are: + "Untracked", "AwaitingFulfillment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OrderState :ivar update_date_time: Time of status update. :vartype update_date_time: ~datetime.datetime - :param comments: Comments related to this status change. - :type comments: str + :ivar comments: Comments related to this status change. + :vartype comments: str :ivar tracking_information: Tracking information related to the state in the ordering flow. :vartype tracking_information: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TrackingInfo :ivar additional_order_details: Dictionary to hold generic information which is not stored @@ -3811,28 +4127,32 @@ class OrderStatus(msrest.serialization.Model): """ _validation = { - 'status': {'required': True}, - 'update_date_time': {'readonly': True}, - 'tracking_information': {'readonly': True}, - 'additional_order_details': {'readonly': True}, + "status": {"required": True}, + "update_date_time": {"readonly": True}, + "tracking_information": {"readonly": True}, + "additional_order_details": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'update_date_time': {'key': 'updateDateTime', 'type': 'iso-8601'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'tracking_information': {'key': 'trackingInformation', 'type': 'TrackingInfo'}, - 'additional_order_details': {'key': 'additionalOrderDetails', 'type': '{str}'}, - } - - def __init__( - self, - *, - status: Union[str, "OrderState"], - comments: Optional[str] = None, - **kwargs - ): - super(OrderStatus, self).__init__(**kwargs) + "status": {"key": "status", "type": "str"}, + "update_date_time": {"key": "updateDateTime", "type": "iso-8601"}, + "comments": {"key": "comments", "type": "str"}, + "tracking_information": {"key": "trackingInformation", "type": "TrackingInfo"}, + "additional_order_details": {"key": "additionalOrderDetails", "type": "{str}"}, + } + + def __init__(self, *, status: Union[str, "_models.OrderState"], comments: Optional[str] = None, **kwargs): + """ + :keyword status: Status of the order as per the allowed status types. Required. Known values + are: "Untracked", "AwaitingFulfillment", "AwaitingPreparation", "AwaitingShipment", "Shipped", + "Arriving", "Delivered", "ReplacementRequested", "LostDevice", "Declined", "ReturnInitiated", + "AwaitingReturnShipment", "ShippedBack", "CollectedAtMicrosoft", "AwaitingPickup", + "PickupCompleted", and "AwaitingDrop". + :paramtype status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.OrderState + :keyword comments: Comments related to this status change. + :paramtype comments: str + """ + super().__init__(**kwargs) self.status = status self.update_date_time = None self.comments = comments @@ -3855,122 +4175,137 @@ class PeriodicTimerEventTrigger(Trigger): :vartype type: str :ivar system_data: Trigger in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param kind: Required. Trigger Kind.Constant filled by server. Possible values include: - "FileEvent", "PeriodicTimerEvent". - :type kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerEventType - :param source_info: Required. Periodic timer details. - :type source_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PeriodicTimerSourceInfo - :param sink_info: Required. Role Sink information. - :type sink_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleSinkInfo - :param custom_context_tag: A custom context tag typically used to correlate the trigger against + :ivar kind: Trigger Kind. Required. Known values are: "FileEvent" and "PeriodicTimerEvent". + :vartype kind: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerEventType + :ivar source_info: Periodic timer details. Required. + :vartype source_info: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PeriodicTimerSourceInfo + :ivar sink_info: Role Sink information. Required. + :vartype sink_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleSinkInfo + :ivar custom_context_tag: A custom context tag typically used to correlate the trigger against its usage. For example, if a periodic timer trigger is intended for certain specific IoT modules in the device, the tag can be the name or the image URL of the module. - :type custom_context_tag: str + :vartype custom_context_tag: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'kind': {'required': True}, - 'source_info': {'required': True}, - 'sink_info': {'required': True}, - 'custom_context_tag': {'max_length': 192, 'min_length': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + "source_info": {"required": True}, + "sink_info": {"required": True}, + "custom_context_tag": {"max_length": 192}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'source_info': {'key': 'properties.sourceInfo', 'type': 'PeriodicTimerSourceInfo'}, - 'sink_info': {'key': 'properties.sinkInfo', 'type': 'RoleSinkInfo'}, - 'custom_context_tag': {'key': 'properties.customContextTag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "source_info": {"key": "properties.sourceInfo", "type": "PeriodicTimerSourceInfo"}, + "sink_info": {"key": "properties.sinkInfo", "type": "RoleSinkInfo"}, + "custom_context_tag": {"key": "properties.customContextTag", "type": "str"}, } def __init__( self, *, - source_info: "PeriodicTimerSourceInfo", - sink_info: "RoleSinkInfo", + source_info: "_models.PeriodicTimerSourceInfo", + sink_info: "_models.RoleSinkInfo", custom_context_tag: Optional[str] = None, **kwargs ): - super(PeriodicTimerEventTrigger, self).__init__(**kwargs) - self.kind = 'PeriodicTimerEvent' # type: str + """ + :keyword source_info: Periodic timer details. Required. + :paramtype source_info: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.PeriodicTimerSourceInfo + :keyword sink_info: Role Sink information. Required. + :paramtype sink_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleSinkInfo + :keyword custom_context_tag: A custom context tag typically used to correlate the trigger + against its usage. For example, if a periodic timer trigger is intended for certain specific + IoT modules in the device, the tag can be the name or the image URL of the module. + :paramtype custom_context_tag: str + """ + super().__init__(**kwargs) + self.kind: str = "PeriodicTimerEvent" self.source_info = source_info self.sink_info = sink_info self.custom_context_tag = custom_context_tag -class PeriodicTimerSourceInfo(msrest.serialization.Model): +class PeriodicTimerSourceInfo(_serialization.Model): """Periodic timer event source. All required parameters must be populated in order to send to Azure. - :param start_time: Required. The time of the day that results in a valid trigger. Schedule is - computed with reference to the time specified upto seconds. If timezone is not specified the - time will considered to be in device timezone. The value will always be returned as UTC time. - :type start_time: ~datetime.datetime - :param schedule: Required. Periodic frequency at which timer event needs to be raised. Supports - daily, hourly, minutes, and seconds. - :type schedule: str - :param topic: Topic where periodic events are published to IoT device. - :type topic: str + :ivar start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :vartype start_time: ~datetime.datetime + :ivar schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :vartype schedule: str + :ivar topic: Topic where periodic events are published to IoT device. + :vartype topic: str """ _validation = { - 'start_time': {'required': True}, - 'schedule': {'required': True}, + "start_time": {"required": True}, + "schedule": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'topic': {'key': 'topic', 'type': 'str'}, - } - - def __init__( - self, - *, - start_time: datetime.datetime, - schedule: str, - topic: Optional[str] = None, - **kwargs - ): - super(PeriodicTimerSourceInfo, self).__init__(**kwargs) + "start_time": {"key": "startTime", "type": "iso-8601"}, + "schedule": {"key": "schedule", "type": "str"}, + "topic": {"key": "topic", "type": "str"}, + } + + def __init__(self, *, start_time: datetime.datetime, schedule: str, topic: Optional[str] = None, **kwargs): + """ + :keyword start_time: The time of the day that results in a valid trigger. Schedule is computed + with reference to the time specified upto seconds. If timezone is not specified the time will + considered to be in device timezone. The value will always be returned as UTC time. Required. + :paramtype start_time: ~datetime.datetime + :keyword schedule: Periodic frequency at which timer event needs to be raised. Supports daily, + hourly, minutes, and seconds. Required. + :paramtype schedule: str + :keyword topic: Topic where periodic events are published to IoT device. + :paramtype topic: str + """ + super().__init__(**kwargs) self.start_time = start_time self.schedule = schedule self.topic = topic -class RefreshDetails(msrest.serialization.Model): +class RefreshDetails(_serialization.Model): """Fields for tracking refresh job on the share or container. - :param in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + :ivar in_progress_refresh_job_id: If a refresh job is currently in progress on this share or container, this field indicates the ARM resource ID of that job. The field is empty if no job is in progress. - :type in_progress_refresh_job_id: str - :param last_completed_refresh_job_time_in_utc: Indicates the completed time for the last - refresh job on this particular share or container, if any.This could be a failed job or a - successful job. - :type last_completed_refresh_job_time_in_utc: ~datetime.datetime - :param error_manifest_file: Indicates the relative path of the error xml for the last refresh + :vartype in_progress_refresh_job_id: str + :ivar last_completed_refresh_job_time_in_utc: Indicates the completed time for the last refresh + job on this particular share or container, if any.This could be a failed job or a successful + job. + :vartype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :ivar error_manifest_file: Indicates the relative path of the error xml for the last refresh job on this particular share or container, if any. This could be a failed job or a successful job. - :type error_manifest_file: str - :param last_job: Indicates the id of the last refresh job on this particular share or + :vartype error_manifest_file: str + :ivar last_job: Indicates the id of the last refresh job on this particular share or container,if any. This could be a failed job or a successful job. - :type last_job: str + :vartype last_job: str """ _attribute_map = { - 'in_progress_refresh_job_id': {'key': 'inProgressRefreshJobId', 'type': 'str'}, - 'last_completed_refresh_job_time_in_utc': {'key': 'lastCompletedRefreshJobTimeInUTC', 'type': 'iso-8601'}, - 'error_manifest_file': {'key': 'errorManifestFile', 'type': 'str'}, - 'last_job': {'key': 'lastJob', 'type': 'str'}, + "in_progress_refresh_job_id": {"key": "inProgressRefreshJobId", "type": "str"}, + "last_completed_refresh_job_time_in_utc": {"key": "lastCompletedRefreshJobTimeInUTC", "type": "iso-8601"}, + "error_manifest_file": {"key": "errorManifestFile", "type": "str"}, + "last_job": {"key": "lastJob", "type": "str"}, } def __init__( @@ -3982,20 +4317,37 @@ def __init__( last_job: Optional[str] = None, **kwargs ): - super(RefreshDetails, self).__init__(**kwargs) + """ + :keyword in_progress_refresh_job_id: If a refresh job is currently in progress on this share or + container, this field indicates the ARM resource ID of that job. The field is empty if no job + is in progress. + :paramtype in_progress_refresh_job_id: str + :keyword last_completed_refresh_job_time_in_utc: Indicates the completed time for the last + refresh job on this particular share or container, if any.This could be a failed job or a + successful job. + :paramtype last_completed_refresh_job_time_in_utc: ~datetime.datetime + :keyword error_manifest_file: Indicates the relative path of the error xml for the last refresh + job on this particular share or container, if any. This could be a failed job or a successful + job. + :paramtype error_manifest_file: str + :keyword last_job: Indicates the id of the last refresh job on this particular share or + container,if any. This could be a failed job or a successful job. + :paramtype last_job: str + """ + super().__init__(**kwargs) self.in_progress_refresh_job_id = in_progress_refresh_job_id self.last_completed_refresh_job_time_in_utc = last_completed_refresh_job_time_in_utc self.error_manifest_file = error_manifest_file self.last_job = last_job -class ResourceIdentity(msrest.serialization.Model): +class ResourceIdentity(_serialization.Model): """Msi identity details of the resource. Variables are only populated by the server, and will be ignored when sending a request. - :param type: Identity type. Possible values include: "None", "SystemAssigned", "UserAssigned". - :type type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MsiIdentityType + :ivar type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :vartype type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MsiIdentityType :ivar principal_id: Service Principal Id backing the Msi. :vartype principal_id: str :ivar tenant_id: Home Tenant Id. @@ -4003,58 +4355,66 @@ class ResourceIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "MsiIdentityType"]] = None, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) + def __init__(self, *, type: Optional[Union[str, "_models.MsiIdentityType"]] = None, **kwargs): + """ + :keyword type: Identity type. Known values are: "None", "SystemAssigned", and "UserAssigned". + :paramtype type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MsiIdentityType + """ + super().__init__(**kwargs) self.type = type self.principal_id = None self.tenant_id = None -class ResourceMoveDetails(msrest.serialization.Model): +class ResourceMoveDetails(_serialization.Model): """Fields for tracking resource move. - :param operation_in_progress: Denotes whether move operation is in progress. Possible values - include: "None", "ResourceMoveInProgress", "ResourceMoveFailed". - :type operation_in_progress: str or + :ivar operation_in_progress: Denotes whether move operation is in progress. Known values are: + "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :vartype operation_in_progress: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceMoveStatus - :param operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + :ivar operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to finish. - :type operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + :vartype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime """ _attribute_map = { - 'operation_in_progress': {'key': 'operationInProgress', 'type': 'str'}, - 'operation_in_progress_lock_timeout_in_utc': {'key': 'operationInProgressLockTimeoutInUTC', 'type': 'iso-8601'}, + "operation_in_progress": {"key": "operationInProgress", "type": "str"}, + "operation_in_progress_lock_timeout_in_utc": {"key": "operationInProgressLockTimeoutInUTC", "type": "iso-8601"}, } def __init__( self, *, - operation_in_progress: Optional[Union[str, "ResourceMoveStatus"]] = None, + operation_in_progress: Optional[Union[str, "_models.ResourceMoveStatus"]] = None, operation_in_progress_lock_timeout_in_utc: Optional[datetime.datetime] = None, **kwargs ): - super(ResourceMoveDetails, self).__init__(**kwargs) + """ + :keyword operation_in_progress: Denotes whether move operation is in progress. Known values + are: "None", "ResourceMoveInProgress", and "ResourceMoveFailed". + :paramtype operation_in_progress: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ResourceMoveStatus + :keyword operation_in_progress_lock_timeout_in_utc: Denotes the timeout of the operation to + finish. + :paramtype operation_in_progress_lock_timeout_in_utc: ~datetime.datetime + """ + super().__init__(**kwargs) self.operation_in_progress = operation_in_progress self.operation_in_progress_lock_timeout_in_utc = operation_in_progress_lock_timeout_in_utc -class ResourceTypeSku(msrest.serialization.Model): +class ResourceTypeSku(_serialization.Model): """Resource type Sku object. Variables are only populated by the server, and will be ignored when sending a request. @@ -4066,25 +4426,23 @@ class ResourceTypeSku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'skus': {'readonly': True}, + "resource_type": {"readonly": True}, + "skus": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'skus': {'key': 'skus', 'type': '[SkuInformation]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "skus": {"key": "skus", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - super(ResourceTypeSku, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.skus = None -class RoleList(msrest.serialization.Model): +class RoleList(_serialization.Model): """Collection of all the roles on the Data Box Edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4096,75 +4454,80 @@ class RoleList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Role]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Role]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(RoleList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class RoleSinkInfo(msrest.serialization.Model): +class RoleSinkInfo(_serialization.Model): """Compute role against which events will be raised. All required parameters must be populated in order to send to Azure. - :param role_id: Required. Compute role ID. - :type role_id: str + :ivar role_id: Compute role ID. Required. + :vartype role_id: str """ _validation = { - 'role_id': {'required': True}, + "role_id": {"required": True}, } _attribute_map = { - 'role_id': {'key': 'roleId', 'type': 'str'}, + "role_id": {"key": "roleId", "type": "str"}, } - def __init__( - self, - *, - role_id: str, - **kwargs - ): - super(RoleSinkInfo, self).__init__(**kwargs) + def __init__(self, *, role_id: str, **kwargs): + """ + :keyword role_id: Compute role ID. Required. + :paramtype role_id: str + """ + super().__init__(**kwargs) self.role_id = role_id -class Secret(msrest.serialization.Model): +class Secret(_serialization.Model): """Holds device secret either as a KeyVault reference or as an encrypted value. - :param encrypted_secret: Encrypted (using device public key) secret value. - :type encrypted_secret: + :ivar encrypted_secret: Encrypted (using device public key) secret value. + :vartype encrypted_secret: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - :param key_vault_id: Id of the Key-Vault where secret is stored (ex: + :ivar key_vault_id: Id of the Key-Vault where secret is stored (ex: secrets/AuthClientSecret/82ef4346187a4033a10d629cde07d740). - :type key_vault_id: str + :vartype key_vault_id: str """ _attribute_map = { - 'encrypted_secret': {'key': 'encryptedSecret', 'type': 'AsymmetricEncryptedSecret'}, - 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, + "encrypted_secret": {"key": "encryptedSecret", "type": "AsymmetricEncryptedSecret"}, + "key_vault_id": {"key": "keyVaultId", "type": "str"}, } def __init__( self, *, - encrypted_secret: Optional["AsymmetricEncryptedSecret"] = None, + encrypted_secret: Optional["_models.AsymmetricEncryptedSecret"] = None, key_vault_id: Optional[str] = None, **kwargs ): - super(Secret, self).__init__(**kwargs) + """ + :keyword encrypted_secret: Encrypted (using device public key) secret value. + :paramtype encrypted_secret: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret + :keyword key_vault_id: Id of the Key-Vault where secret is stored (ex: + secrets/AuthClientSecret/82ef4346187a4033a10d629cde07d740). + :paramtype key_vault_id: str + """ + super().__init__(**kwargs) self.encrypted_secret = encrypted_secret self.key_vault_id = key_vault_id @@ -4182,61 +4545,64 @@ class SecuritySettings(ARMBaseModel): :vartype name: str :ivar type: The hierarchical type of the object. :vartype type: str - :param device_admin_password: Required. Device administrator password as an encrypted string - (encrypted using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual - password should have at least 8 characters that are a combination of uppercase, lowercase, - numeric, and special characters. - :type device_admin_password: + :ivar device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :vartype device_admin_password: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'device_admin_password': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "device_admin_password": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'device_admin_password': {'key': 'properties.deviceAdminPassword', 'type': 'AsymmetricEncryptedSecret'}, - } - - def __init__( - self, - *, - device_admin_password: "AsymmetricEncryptedSecret", - **kwargs - ): - super(SecuritySettings, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "device_admin_password": {"key": "properties.deviceAdminPassword", "type": "AsymmetricEncryptedSecret"}, + } + + def __init__(self, *, device_admin_password: "_models.AsymmetricEncryptedSecret", **kwargs): + """ + :keyword device_admin_password: Device administrator password as an encrypted string (encrypted + using RSA PKCS #1) is used to sign into the local web UI of the device. The Actual password + should have at least 8 characters that are a combination of uppercase, lowercase, numeric, and + special characters. Required. + :paramtype device_admin_password: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.device_admin_password = device_admin_password -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification. - :param metric_specifications: Metric specification as defined by shoebox. - :type metric_specifications: + :ivar metric_specifications: Metric specification as defined by shoebox. + :vartype metric_specifications: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricSpecificationV1] """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecificationV1]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecificationV1]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["MetricSpecificationV1"]] = None, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecificationV1"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specification as defined by shoebox. + :paramtype metric_specifications: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MetricSpecificationV1] + """ + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Share(ARMBaseModel): +class Share(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Represents a share on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4251,81 +4617,111 @@ class Share(ARMBaseModel): :vartype type: str :ivar system_data: Share on ASE device. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param description: Description for the share. - :type description: str - :param share_status: Required. Current status of the share. Possible values include: "Offline", - "Unknown", "OK", "Updating", "NeedsAttention". - :type share_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareStatus - :param monitoring_status: Required. Current monitoring status of the share. Possible values - include: "Enabled", "Disabled". - :type monitoring_status: str or + :ivar description: Description for the share. + :vartype description: str + :ivar share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :vartype share_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareStatus + :ivar monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :vartype monitoring_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringStatus - :param azure_container_info: Azure container mapping for the share. - :type azure_container_info: + :ivar azure_container_info: Azure container mapping for the share. + :vartype azure_container_info: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AzureContainerInfo - :param access_protocol: Required. Access protocol to be used by the share. Possible values - include: "SMB", "NFS". - :type access_protocol: str or + :ivar access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :vartype access_protocol: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessProtocol - :param user_access_rights: Mapping of users and corresponding access rights on the share + :ivar user_access_rights: Mapping of users and corresponding access rights on the share (required for SMB protocol). - :type user_access_rights: + :vartype user_access_rights: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.UserAccessRight] - :param client_access_rights: List of IP addresses and corresponding access rights on the + :ivar client_access_rights: List of IP addresses and corresponding access rights on the share(required for NFS protocol). - :type client_access_rights: + :vartype client_access_rights: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ClientAccessRight] - :param refresh_details: Details of the refresh job on this share. - :type refresh_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RefreshDetails + :ivar refresh_details: Details of the refresh job on this share. + :vartype refresh_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RefreshDetails :ivar share_mappings: Share mount point to the role. :vartype share_mappings: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MountPointMap] - :param data_policy: Data policy of the share. Possible values include: "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataPolicy + :ivar data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataPolicy """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_status': {'required': True}, - 'monitoring_status': {'required': True}, - 'access_protocol': {'required': True}, - 'share_mappings': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_status": {"required": True}, + "monitoring_status": {"required": True}, + "access_protocol": {"required": True}, + "share_mappings": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'share_status': {'key': 'properties.shareStatus', 'type': 'str'}, - 'monitoring_status': {'key': 'properties.monitoringStatus', 'type': 'str'}, - 'azure_container_info': {'key': 'properties.azureContainerInfo', 'type': 'AzureContainerInfo'}, - 'access_protocol': {'key': 'properties.accessProtocol', 'type': 'str'}, - 'user_access_rights': {'key': 'properties.userAccessRights', 'type': '[UserAccessRight]'}, - 'client_access_rights': {'key': 'properties.clientAccessRights', 'type': '[ClientAccessRight]'}, - 'refresh_details': {'key': 'properties.refreshDetails', 'type': 'RefreshDetails'}, - 'share_mappings': {'key': 'properties.shareMappings', 'type': '[MountPointMap]'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "share_status": {"key": "properties.shareStatus", "type": "str"}, + "monitoring_status": {"key": "properties.monitoringStatus", "type": "str"}, + "azure_container_info": {"key": "properties.azureContainerInfo", "type": "AzureContainerInfo"}, + "access_protocol": {"key": "properties.accessProtocol", "type": "str"}, + "user_access_rights": {"key": "properties.userAccessRights", "type": "[UserAccessRight]"}, + "client_access_rights": {"key": "properties.clientAccessRights", "type": "[ClientAccessRight]"}, + "refresh_details": {"key": "properties.refreshDetails", "type": "RefreshDetails"}, + "share_mappings": {"key": "properties.shareMappings", "type": "[MountPointMap]"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, } def __init__( self, *, - share_status: Union[str, "ShareStatus"], - monitoring_status: Union[str, "MonitoringStatus"], - access_protocol: Union[str, "ShareAccessProtocol"], + share_status: Union[str, "_models.ShareStatus"], + monitoring_status: Union[str, "_models.MonitoringStatus"], + access_protocol: Union[str, "_models.ShareAccessProtocol"], description: Optional[str] = None, - azure_container_info: Optional["AzureContainerInfo"] = None, - user_access_rights: Optional[List["UserAccessRight"]] = None, - client_access_rights: Optional[List["ClientAccessRight"]] = None, - refresh_details: Optional["RefreshDetails"] = None, - data_policy: Optional[Union[str, "DataPolicy"]] = None, + azure_container_info: Optional["_models.AzureContainerInfo"] = None, + user_access_rights: Optional[List["_models.UserAccessRight"]] = None, + client_access_rights: Optional[List["_models.ClientAccessRight"]] = None, + refresh_details: Optional["_models.RefreshDetails"] = None, + data_policy: Optional[Union[str, "_models.DataPolicy"]] = None, **kwargs ): - super(Share, self).__init__(**kwargs) + """ + :keyword description: Description for the share. + :paramtype description: str + :keyword share_status: Current status of the share. Required. Known values are: "Offline", + "Unknown", "OK", "Updating", and "NeedsAttention". + :paramtype share_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareStatus + :keyword monitoring_status: Current monitoring status of the share. Required. Known values are: + "Enabled" and "Disabled". + :paramtype monitoring_status: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringStatus + :keyword azure_container_info: Azure container mapping for the share. + :paramtype azure_container_info: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AzureContainerInfo + :keyword access_protocol: Access protocol to be used by the share. Required. Known values are: + "SMB" and "NFS". + :paramtype access_protocol: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessProtocol + :keyword user_access_rights: Mapping of users and corresponding access rights on the share + (required for SMB protocol). + :paramtype user_access_rights: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.UserAccessRight] + :keyword client_access_rights: List of IP addresses and corresponding access rights on the + share(required for NFS protocol). + :paramtype client_access_rights: + list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ClientAccessRight] + :keyword refresh_details: Details of the refresh job on this share. + :paramtype refresh_details: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.RefreshDetails + :keyword data_policy: Data policy of the share. Known values are: "Cloud" and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataPolicy + """ + super().__init__(**kwargs) self.system_data = None self.description = description self.share_status = share_status @@ -4339,41 +4735,43 @@ def __init__( self.data_policy = data_policy -class ShareAccessRight(msrest.serialization.Model): +class ShareAccessRight(_serialization.Model): """Specifies the mapping between this particular user and the type of access he has on shares on this device. All required parameters must be populated in order to send to Azure. - :param share_id: Required. The share ID. - :type share_id: str - :param access_type: Required. Type of access to be allowed on the share for this user. Possible - values include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessType + :ivar share_id: The share ID. Required. + :vartype share_id: str + :ivar access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessType """ _validation = { - 'share_id': {'required': True}, - 'access_type': {'required': True}, + "share_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'share_id': {'key': 'shareId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - share_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(ShareAccessRight, self).__init__(**kwargs) + "share_id": {"key": "shareId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, share_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword share_id: The share ID. Required. + :paramtype share_id: str + :keyword access_type: Type of access to be allowed on the share for this user. Required. Known + values are: "Change", "Read", and "Custom". + :paramtype access_type: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessType + """ + super().__init__(**kwargs) self.share_id = share_id self.access_type = access_type -class ShareList(msrest.serialization.Model): +class ShareList(_serialization.Model): """Collection of all the shares on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4385,55 +4783,91 @@ class ShareList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Share]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Share]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ShareList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU type. - :param name: SKU name. Possible values include: "Gateway", "Edge", "TEA_1Node", - "TEA_1Node_UPS", "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", - "TEA_4Node_UPS_Heater", "TMA", "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", - "EdgeP_High", "EdgePR_Base", "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", - "EP2_256_2T4_W", "EdgeMR_Mini", "RCA_Small", "RCA_Large", "RDC", "Management". - :type name: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuName - :param tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard". - :type tier: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuTier + :ivar name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", "EP2_256_2T4_W", "EdgeMR_Mini", + "RCA_Small", "RCA_Large", "RDC", and "Management". + :vartype name: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. "Standard" + :vartype tier: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuTier """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( self, *, - name: Optional[Union[str, "SkuName"]] = None, - tier: Optional[Union[str, "SkuTier"]] = None, + name: Optional[Union[str, "_models.SkuName"]] = None, + tier: Optional[Union[str, "_models.SkuTier"]] = None, **kwargs ): - super(Sku, self).__init__(**kwargs) + """ + :keyword name: SKU name. Known values are: "Gateway", "Edge", "TEA_1Node", "TEA_1Node_UPS", + "TEA_1Node_Heater", "TEA_1Node_UPS_Heater", "TEA_4Node_Heater", "TEA_4Node_UPS_Heater", "TMA", + "TDC", "TCA_Small", "GPU", "TCA_Large", "EdgeP_Base", "EdgeP_High", "EdgePR_Base", + "EdgePR_Base_UPS", "EP2_64_1VPU_W", "EP2_128_1T4_Mx1_W", "EP2_256_2T4_W", "EdgeMR_Mini", + "RCA_Small", "RCA_Large", "RDC", and "Management". + :paramtype name: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuName + :keyword tier: The SKU tier. This is based on the SKU name. "Standard" + :paramtype tier: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SkuTier + """ + super().__init__(**kwargs) self.name = name self.tier = tier -class SkuCost(msrest.serialization.Model): +class SkuCapability(_serialization.Model): + """The metadata to describe the capability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: An invariant to describe the feature. + :vartype name: str + :ivar value: An invariant if the feature is measured by quantity. + :vartype value: str + """ + + _validation = { + "name": {"readonly": True}, + "value": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.value = None + + +class SkuCost(_serialization.Model): """The metadata for retrieving price info. Variables are only populated by the server, and will be ignored when sending a request. @@ -4441,34 +4875,32 @@ class SkuCost(msrest.serialization.Model): :ivar meter_id: Used for querying price from commerce. :vartype meter_id: str :ivar quantity: The cost quantity. - :vartype quantity: long + :vartype quantity: int :ivar extended_unit: The extended unit. :vartype extended_unit: str """ _validation = { - 'meter_id': {'readonly': True}, - 'quantity': {'readonly': True}, - 'extended_unit': {'readonly': True}, + "meter_id": {"readonly": True}, + "quantity": {"readonly": True}, + "extended_unit": {"readonly": True}, } _attribute_map = { - 'meter_id': {'key': 'meterId', 'type': 'str'}, - 'quantity': {'key': 'quantity', 'type': 'long'}, - 'extended_unit': {'key': 'extendedUnit', 'type': 'str'}, + "meter_id": {"key": "meterId", "type": "str"}, + "quantity": {"key": "quantity", "type": "int"}, + "extended_unit": {"key": "extendedUnit", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuCost, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.meter_id = None self.quantity = None self.extended_unit = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Sku information. Variables are only populated by the server, and will be ignored when sending a request. @@ -4495,34 +4927,32 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'kind': {'readonly': True}, - 'family': {'readonly': True}, - 'costs': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'required_quota_ids': {'readonly': True}, - 'required_features': {'readonly': True}, + "name": {"readonly": True}, + "tier": {"readonly": True}, + "kind": {"readonly": True}, + "family": {"readonly": True}, + "costs": {"readonly": True}, + "locations": {"readonly": True}, + "location_info": {"readonly": True}, + "required_quota_ids": {"readonly": True}, + "required_features": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'costs': {'key': 'costs', 'type': '[SkuCost]'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfo]'}, - 'required_quota_ids': {'key': 'requiredQuotaIds', 'type': '[str]'}, - 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuInformation, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "costs": {"key": "costs", "type": "[SkuCost]"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfo]"}, + "required_quota_ids": {"key": "requiredQuotaIds", "type": "[str]"}, + "required_features": {"key": "requiredFeatures", "type": "[str]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.tier = None self.kind = None @@ -4534,7 +4964,7 @@ def __init__( self.required_features = None -class SkuInformationList(msrest.serialization.Model): +class SkuInformationList(_serialization.Model): """List of SKU Information objects. Variables are only populated by the server, and will be ignored when sending a request. @@ -4546,25 +4976,23 @@ class SkuInformationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ResourceTypeSku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(SkuInformationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SkuLocationInfo(msrest.serialization.Model): +class SkuLocationInfo(_serialization.Model): """The location info. Variables are only populated by the server, and will be ignored when sending a request. @@ -4578,22 +5006,20 @@ class SkuLocationInfo(msrest.serialization.Model): """ _validation = { - 'location': {'readonly': True}, - 'zones': {'readonly': True}, - 'sites': {'readonly': True}, + "location": {"readonly": True}, + "zones": {"readonly": True}, + "sites": {"readonly": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'sites': {'key': 'sites', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "sites": {"key": "sites", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - super(SkuLocationInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.zones = None self.sites = None @@ -4614,17 +5040,17 @@ class StorageAccount(ARMBaseModel): :vartype type: str :ivar system_data: StorageAccount object on ASE device. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param description: Description for the storage Account. - :type description: str - :param storage_account_status: Current status of the storage account. Possible values include: - "OK", "Offline", "Unknown", "Updating", "NeedsAttention". - :type storage_account_status: str or + :ivar description: Description for the storage Account. + :vartype description: str + :ivar storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :vartype storage_account_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountStatus - :param data_policy: Required. Data policy of the storage Account. Possible values include: - "Cloud", "Local". - :type data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataPolicy - :param storage_account_credential_id: Storage Account Credential Id. - :type storage_account_credential_id: str + :ivar data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" and + "Local". + :vartype data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataPolicy + :ivar storage_account_credential_id: Storage Account Credential Id. + :vartype storage_account_credential_id: str :ivar blob_endpoint: BlobEndpoint of Storage Account. :vartype blob_endpoint: str :ivar container_count: The Container Count. Present only for Storage Accounts with DataPolicy @@ -4633,38 +5059,51 @@ class StorageAccount(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'data_policy': {'required': True}, - 'blob_endpoint': {'readonly': True}, - 'container_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "data_policy": {"required": True}, + "blob_endpoint": {"readonly": True}, + "container_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'storage_account_status': {'key': 'properties.storageAccountStatus', 'type': 'str'}, - 'data_policy': {'key': 'properties.dataPolicy', 'type': 'str'}, - 'storage_account_credential_id': {'key': 'properties.storageAccountCredentialId', 'type': 'str'}, - 'blob_endpoint': {'key': 'properties.blobEndpoint', 'type': 'str'}, - 'container_count': {'key': 'properties.containerCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "storage_account_status": {"key": "properties.storageAccountStatus", "type": "str"}, + "data_policy": {"key": "properties.dataPolicy", "type": "str"}, + "storage_account_credential_id": {"key": "properties.storageAccountCredentialId", "type": "str"}, + "blob_endpoint": {"key": "properties.blobEndpoint", "type": "str"}, + "container_count": {"key": "properties.containerCount", "type": "int"}, } def __init__( self, *, - data_policy: Union[str, "DataPolicy"], + data_policy: Union[str, "_models.DataPolicy"], description: Optional[str] = None, - storage_account_status: Optional[Union[str, "StorageAccountStatus"]] = None, + storage_account_status: Optional[Union[str, "_models.StorageAccountStatus"]] = None, storage_account_credential_id: Optional[str] = None, **kwargs ): - super(StorageAccount, self).__init__(**kwargs) + """ + :keyword description: Description for the storage Account. + :paramtype description: str + :keyword storage_account_status: Current status of the storage account. Known values are: "OK", + "Offline", "Unknown", "Updating", and "NeedsAttention". + :paramtype storage_account_status: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountStatus + :keyword data_policy: Data policy of the storage Account. Required. Known values are: "Cloud" + and "Local". + :paramtype data_policy: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataPolicy + :keyword storage_account_credential_id: Storage Account Credential Id. + :paramtype storage_account_credential_id: str + """ + super().__init__(**kwargs) self.system_data = None self.description = description self.storage_account_status = storage_account_status @@ -4674,7 +5113,7 @@ def __init__( self.container_count = None -class StorageAccountCredential(ARMBaseModel): +class StorageAccountCredential(ARMBaseModel): # pylint: disable=too-many-instance-attributes """The storage account credential. Variables are only populated by the server, and will be ignored when sending a request. @@ -4689,66 +5128,89 @@ class StorageAccountCredential(ARMBaseModel): :vartype type: str :ivar system_data: StorageAccountCredential object. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param alias: Required. Alias for the storage account. - :type alias: str - :param user_name: Username for the storage account. - :type user_name: str - :param account_key: Encrypted storage key. - :type account_key: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret - :param connection_string: Connection string for the storage account. Use this string if - username and account key are not specified. - :type connection_string: str - :param ssl_status: Required. Signifies whether SSL needs to be enabled or not. Possible values - include: "Enabled", "Disabled". - :type ssl_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SSLStatus - :param blob_domain_name: Blob end point for private clouds. - :type blob_domain_name: str - :param account_type: Required. Type of storage accessed on the storage account. Possible values - include: "GeneralPurposeStorage", "BlobStorage". - :type account_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AccountType - :param storage_account_id: Id of the storage account. - :type storage_account_id: str + :ivar alias: Alias for the storage account. Required. + :vartype alias: str + :ivar user_name: Username for the storage account. + :vartype user_name: str + :ivar account_key: Encrypted storage key. + :vartype account_key: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret + :ivar connection_string: Connection string for the storage account. Use this string if username + and account key are not specified. + :vartype connection_string: str + :ivar ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values are: + "Enabled" and "Disabled". + :vartype ssl_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SSLStatus + :ivar blob_domain_name: Blob end point for private clouds. + :vartype blob_domain_name: str + :ivar account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :vartype account_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AccountType + :ivar storage_account_id: Id of the storage account. + :vartype storage_account_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'alias': {'required': True}, - 'ssl_status': {'required': True}, - 'account_type': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "alias": {"required": True}, + "ssl_status": {"required": True}, + "account_type": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'alias': {'key': 'properties.alias', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'account_key': {'key': 'properties.accountKey', 'type': 'AsymmetricEncryptedSecret'}, - 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, - 'ssl_status': {'key': 'properties.sslStatus', 'type': 'str'}, - 'blob_domain_name': {'key': 'properties.blobDomainName', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "alias": {"key": "properties.alias", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "account_key": {"key": "properties.accountKey", "type": "AsymmetricEncryptedSecret"}, + "connection_string": {"key": "properties.connectionString", "type": "str"}, + "ssl_status": {"key": "properties.sslStatus", "type": "str"}, + "blob_domain_name": {"key": "properties.blobDomainName", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "storage_account_id": {"key": "properties.storageAccountId", "type": "str"}, } def __init__( self, *, alias: str, - ssl_status: Union[str, "SSLStatus"], - account_type: Union[str, "AccountType"], + ssl_status: Union[str, "_models.SSLStatus"], + account_type: Union[str, "_models.AccountType"], user_name: Optional[str] = None, - account_key: Optional["AsymmetricEncryptedSecret"] = None, + account_key: Optional["_models.AsymmetricEncryptedSecret"] = None, connection_string: Optional[str] = None, blob_domain_name: Optional[str] = None, storage_account_id: Optional[str] = None, **kwargs ): - super(StorageAccountCredential, self).__init__(**kwargs) + """ + :keyword alias: Alias for the storage account. Required. + :paramtype alias: str + :keyword user_name: Username for the storage account. + :paramtype user_name: str + :keyword account_key: Encrypted storage key. + :paramtype account_key: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret + :keyword connection_string: Connection string for the storage account. Use this string if + username and account key are not specified. + :paramtype connection_string: str + :keyword ssl_status: Signifies whether SSL needs to be enabled or not. Required. Known values + are: "Enabled" and "Disabled". + :paramtype ssl_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SSLStatus + :keyword blob_domain_name: Blob end point for private clouds. + :paramtype blob_domain_name: str + :keyword account_type: Type of storage accessed on the storage account. Required. Known values + are: "GeneralPurposeStorage" and "BlobStorage". + :paramtype account_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AccountType + :keyword storage_account_id: Id of the storage account. + :paramtype storage_account_id: str + """ + super().__init__(**kwargs) self.system_data = None self.alias = alias self.user_name = user_name @@ -4760,7 +5222,7 @@ def __init__( self.storage_account_id = storage_account_id -class StorageAccountCredentialList(msrest.serialization.Model): +class StorageAccountCredentialList(_serialization.Model): """The collection of storage account credentials. Variables are only populated by the server, and will be ignored when sending a request. @@ -4773,25 +5235,23 @@ class StorageAccountCredentialList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccountCredential]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccountCredential]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountCredentialList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountList(msrest.serialization.Model): +class StorageAccountList(_serialization.Model): """Collection of all the Storage Accounts on the Data Box Edge/Gateway device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4803,113 +5263,130 @@ class StorageAccountList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(StorageAccountList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SubscriptionRegisteredFeatures(msrest.serialization.Model): +class SubscriptionRegisteredFeatures(_serialization.Model): """SubscriptionRegisteredFeatures. - :param name: - :type name: str - :param state: - :type state: str + :ivar name: + :vartype name: str + :ivar state: + :vartype state: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - state: Optional[str] = None, - **kwargs - ): - super(SubscriptionRegisteredFeatures, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, state: Optional[str] = None, **kwargs): + """ + :keyword name: + :paramtype name: str + :keyword state: + :paramtype state: str + """ + super().__init__(**kwargs) self.name = name self.state = state -class SymmetricKey(msrest.serialization.Model): +class SymmetricKey(_serialization.Model): """Symmetric key for authentication. - :param connection_string: Connection string based on the symmetric key. - :type connection_string: + :ivar connection_string: Connection string based on the symmetric key. + :vartype connection_string: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret """ _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'AsymmetricEncryptedSecret'}, + "connection_string": {"key": "connectionString", "type": "AsymmetricEncryptedSecret"}, } - def __init__( - self, - *, - connection_string: Optional["AsymmetricEncryptedSecret"] = None, - **kwargs - ): - super(SymmetricKey, self).__init__(**kwargs) + def __init__(self, *, connection_string: Optional["_models.AsymmetricEncryptedSecret"] = None, **kwargs): + """ + :keyword connection_string: Connection string based on the symmetric key. + :paramtype connection_string: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret + """ + super().__init__(**kwargs) self.connection_string = connection_string -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or + ~azure.mgmt.databoxedge.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", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the resource. - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The type of identity that last modified the resource. + :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'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_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, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(SystemData, self).__init__(**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", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.databoxedge.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", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.CreatedByType + :keyword last_modified_at: The type of identity that last modified the resource. + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -4918,24 +5395,24 @@ def __init__( self.last_modified_at = last_modified_at -class TrackingInfo(msrest.serialization.Model): +class TrackingInfo(_serialization.Model): """Tracking courier information. - :param serial_number: Serial number of the device being tracked. - :type serial_number: str - :param carrier_name: Name of the carrier used in the delivery. - :type carrier_name: str - :param tracking_id: Tracking ID of the shipment. - :type tracking_id: str - :param tracking_url: Tracking URL of the shipment. - :type tracking_url: str + :ivar serial_number: Serial number of the device being tracked. + :vartype serial_number: str + :ivar carrier_name: Name of the carrier used in the delivery. + :vartype carrier_name: str + :ivar tracking_id: Tracking ID of the shipment. + :vartype tracking_id: str + :ivar tracking_url: Tracking URL of the shipment. + :vartype tracking_url: str """ _attribute_map = { - 'serial_number': {'key': 'serialNumber', 'type': 'str'}, - 'carrier_name': {'key': 'carrierName', 'type': 'str'}, - 'tracking_id': {'key': 'trackingId', 'type': 'str'}, - 'tracking_url': {'key': 'trackingUrl', 'type': 'str'}, + "serial_number": {"key": "serialNumber", "type": "str"}, + "carrier_name": {"key": "carrierName", "type": "str"}, + "tracking_id": {"key": "trackingId", "type": "str"}, + "tracking_url": {"key": "trackingUrl", "type": "str"}, } def __init__( @@ -4947,14 +5424,24 @@ def __init__( tracking_url: Optional[str] = None, **kwargs ): - super(TrackingInfo, self).__init__(**kwargs) + """ + :keyword serial_number: Serial number of the device being tracked. + :paramtype serial_number: str + :keyword carrier_name: Name of the carrier used in the delivery. + :paramtype carrier_name: str + :keyword tracking_id: Tracking ID of the shipment. + :paramtype tracking_id: str + :keyword tracking_url: Tracking URL of the shipment. + :paramtype tracking_url: str + """ + super().__init__(**kwargs) self.serial_number = serial_number self.carrier_name = carrier_name self.tracking_id = tracking_id self.tracking_url = tracking_url -class TriggerList(msrest.serialization.Model): +class TriggerList(_serialization.Model): """Collection of all trigger on the data box edge device. Variables are only populated by the server, and will be ignored when sending a request. @@ -4966,55 +5453,53 @@ class TriggerList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Trigger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Trigger]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(TriggerList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class UpdateDetails(msrest.serialization.Model): +class UpdateDetails(_serialization.Model): """Update Specific attributes. - :param update_title: Title of the Update. - :type update_title: str - :param update_size: Size of the update(In Bytes). - :type update_size: float - :param update_type: Type of the Update. Possible values include: "Software", "Kubernetes", + :ivar update_title: Title of the Update. + :vartype update_title: str + :ivar update_size: Size of the update(In Bytes). + :vartype update_size: float + :ivar update_type: Type of the Update. Known values are: "Software", "Kubernetes", and "Firmware". - :type update_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateType - :param target_version: Target Version number. - :type target_version: str - :param estimated_install_time_in_mins: Estimated Install Time for the update. - :type estimated_install_time_in_mins: int - :param reboot_behavior: Indicates if updates are available and at least one of the updates - needs a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". - :type reboot_behavior: str or + :vartype update_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateType + :ivar target_version: Target Version number. + :vartype target_version: str + :ivar estimated_install_time_in_mins: Estimated Install Time for the update. + :vartype estimated_install_time_in_mins: int + :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". + :vartype reboot_behavior: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.InstallRebootBehavior - :param status: Status of the update. Possible values include: "DownloadPending", - "DownloadStarted", "DownloadCompleted", "InstallStarted", "InstallCompleted". - :type status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateStatus + :ivar status: Status of the update. Known values are: "DownloadPending", "DownloadStarted", + "DownloadCompleted", "InstallStarted", and "InstallCompleted". + :vartype status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateStatus """ _attribute_map = { - 'update_title': {'key': 'updateTitle', 'type': 'str'}, - 'update_size': {'key': 'updateSize', 'type': 'float'}, - 'update_type': {'key': 'updateType', 'type': 'str'}, - 'target_version': {'key': 'targetVersion', 'type': 'str'}, - 'estimated_install_time_in_mins': {'key': 'estimatedInstallTimeInMins', 'type': 'int'}, - 'reboot_behavior': {'key': 'rebootBehavior', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "update_title": {"key": "updateTitle", "type": "str"}, + "update_size": {"key": "updateSize", "type": "float"}, + "update_type": {"key": "updateType", "type": "str"}, + "target_version": {"key": "targetVersion", "type": "str"}, + "estimated_install_time_in_mins": {"key": "estimatedInstallTimeInMins", "type": "int"}, + "reboot_behavior": {"key": "rebootBehavior", "type": "str"}, + "status": {"key": "status", "type": "str"}, } def __init__( @@ -5022,14 +5507,34 @@ def __init__( *, update_title: Optional[str] = None, update_size: Optional[float] = None, - update_type: Optional[Union[str, "UpdateType"]] = None, + update_type: Optional[Union[str, "_models.UpdateType"]] = None, target_version: Optional[str] = None, estimated_install_time_in_mins: Optional[int] = None, - reboot_behavior: Optional[Union[str, "InstallRebootBehavior"]] = None, - status: Optional[Union[str, "UpdateStatus"]] = None, + reboot_behavior: Optional[Union[str, "_models.InstallRebootBehavior"]] = None, + status: Optional[Union[str, "_models.UpdateStatus"]] = None, **kwargs ): - super(UpdateDetails, self).__init__(**kwargs) + """ + :keyword update_title: Title of the Update. + :paramtype update_title: str + :keyword update_size: Size of the update(In Bytes). + :paramtype update_size: float + :keyword update_type: Type of the Update. Known values are: "Software", "Kubernetes", and + "Firmware". + :paramtype update_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateType + :keyword target_version: Target Version number. + :paramtype target_version: str + :keyword estimated_install_time_in_mins: Estimated Install Time for the update. + :paramtype estimated_install_time_in_mins: int + :keyword reboot_behavior: Indicates if updates are available and at least one of the updates + needs a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". + :paramtype reboot_behavior: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.InstallRebootBehavior + :keyword status: Status of the update. Known values are: "DownloadPending", "DownloadStarted", + "DownloadCompleted", "InstallStarted", and "InstallCompleted". + :paramtype status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateStatus + """ + super().__init__(**kwargs) self.update_title = update_title self.update_size = update_size self.update_type = update_type @@ -5039,13 +5544,13 @@ def __init__( self.status = status -class UpdateDownloadProgress(msrest.serialization.Model): +class UpdateDownloadProgress(_serialization.Model): """Details about the download progress of update. Variables are only populated by the server, and will be ignored when sending a request. - :ivar download_phase: The download phase. Possible values include: "Unknown", "Initializing", - "Downloading", "Verifying". + :ivar download_phase: The download phase. Known values are: "Unknown", "Initializing", + "Downloading", and "Verifying". :vartype download_phase: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DownloadPhase :ivar percent_complete: Percentage of completion. @@ -5061,28 +5566,26 @@ class UpdateDownloadProgress(msrest.serialization.Model): """ _validation = { - 'download_phase': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'total_bytes_to_download': {'readonly': True}, - 'total_bytes_downloaded': {'readonly': True}, - 'number_of_updates_to_download': {'readonly': True}, - 'number_of_updates_downloaded': {'readonly': True}, + "download_phase": {"readonly": True}, + "percent_complete": {"readonly": True}, + "total_bytes_to_download": {"readonly": True}, + "total_bytes_downloaded": {"readonly": True}, + "number_of_updates_to_download": {"readonly": True}, + "number_of_updates_downloaded": {"readonly": True}, } _attribute_map = { - 'download_phase': {'key': 'downloadPhase', 'type': 'str'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'total_bytes_to_download': {'key': 'totalBytesToDownload', 'type': 'float'}, - 'total_bytes_downloaded': {'key': 'totalBytesDownloaded', 'type': 'float'}, - 'number_of_updates_to_download': {'key': 'numberOfUpdatesToDownload', 'type': 'int'}, - 'number_of_updates_downloaded': {'key': 'numberOfUpdatesDownloaded', 'type': 'int'}, + "download_phase": {"key": "downloadPhase", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "total_bytes_to_download": {"key": "totalBytesToDownload", "type": "float"}, + "total_bytes_downloaded": {"key": "totalBytesDownloaded", "type": "float"}, + "number_of_updates_to_download": {"key": "numberOfUpdatesToDownload", "type": "int"}, + "number_of_updates_downloaded": {"key": "numberOfUpdatesDownloaded", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateDownloadProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.download_phase = None self.percent_complete = None self.total_bytes_to_download = None @@ -5091,7 +5594,7 @@ def __init__( self.number_of_updates_downloaded = None -class UpdateInstallProgress(msrest.serialization.Model): +class UpdateInstallProgress(_serialization.Model): """Progress details during installation of updates. Variables are only populated by the server, and will be ignored when sending a request. @@ -5105,28 +5608,26 @@ class UpdateInstallProgress(msrest.serialization.Model): """ _validation = { - 'percent_complete': {'readonly': True}, - 'number_of_updates_to_install': {'readonly': True}, - 'number_of_updates_installed': {'readonly': True}, + "percent_complete": {"readonly": True}, + "number_of_updates_to_install": {"readonly": True}, + "number_of_updates_installed": {"readonly": True}, } _attribute_map = { - 'percent_complete': {'key': 'percentComplete', 'type': 'int'}, - 'number_of_updates_to_install': {'key': 'numberOfUpdatesToInstall', 'type': 'int'}, - 'number_of_updates_installed': {'key': 'numberOfUpdatesInstalled', 'type': 'int'}, + "percent_complete": {"key": "percentComplete", "type": "int"}, + "number_of_updates_to_install": {"key": "numberOfUpdatesToInstall", "type": "int"}, + "number_of_updates_installed": {"key": "numberOfUpdatesInstalled", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(UpdateInstallProgress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.percent_complete = None self.number_of_updates_to_install = None self.number_of_updates_installed = None -class UpdateSummary(ARMBaseModel): +class UpdateSummary(ARMBaseModel): # pylint: disable=too-many-instance-attributes """Details about ongoing updates and availability of updates on the device. Variables are only populated by the server, and will be ignored when sending a request. @@ -5139,23 +5640,23 @@ class UpdateSummary(ARMBaseModel): :vartype type: str :ivar system_data: UpdateSummary Result. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param device_version_number: The current version of the device in format: 1.2.17312.13.",. - :type device_version_number: str - :param friendly_device_version_name: The current version of the device in text format. - :type friendly_device_version_name: str - :param device_last_scanned_date_time: The last time when a scan was done on the device. - :type device_last_scanned_date_time: ~datetime.datetime - :param last_completed_scan_job_date_time: The time when the last scan job was completed + :ivar device_version_number: The current version of the device in format: 1.2.17312.13.",. + :vartype device_version_number: str + :ivar friendly_device_version_name: The current version of the device in text format. + :vartype friendly_device_version_name: str + :ivar device_last_scanned_date_time: The last time when a scan was done on the device. + :vartype device_last_scanned_date_time: ~datetime.datetime + :ivar last_completed_scan_job_date_time: The time when the last scan job was completed (success/cancelled/failed) on the appliance. - :type last_completed_scan_job_date_time: ~datetime.datetime + :vartype last_completed_scan_job_date_time: ~datetime.datetime :ivar last_completed_download_job_date_time: The time when the last Download job was completed (success/cancelled/failed) on the appliance. :vartype last_completed_download_job_date_time: ~datetime.datetime :ivar last_completed_download_job_id: JobId of the last ran download job.(Can be success/cancelled/failed). :vartype last_completed_download_job_id: str - :ivar last_download_job_status: JobStatus of the last ran download job. Possible values - include: "Invalid", "Running", "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar last_download_job_status: JobStatus of the last ran download job. Known values are: + "Invalid", "Running", "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype last_download_job_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobStatus :ivar last_completed_install_job_date_time: The time when the last Install job was completed @@ -5164,8 +5665,8 @@ class UpdateSummary(ARMBaseModel): :ivar last_completed_install_job_id: JobId of the last ran install job.(Can be success/cancelled/failed). :vartype last_completed_install_job_id: str - :ivar last_install_job_status: JobStatus of the last ran install job. Possible values include: - "Invalid", "Running", "Succeeded", "Failed", "Canceled", "Paused", "Scheduled". + :ivar last_install_job_status: JobStatus of the last ran install job. Known values are: + "Invalid", "Running", "Succeeded", "Failed", "Canceled", "Paused", and "Scheduled". :vartype last_install_job_status: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.JobStatus :ivar total_number_of_updates_available: The number of updates available for the current device @@ -5176,11 +5677,11 @@ class UpdateSummary(ARMBaseModel): :ivar total_number_of_updates_pending_install: The total number of items pending install. :vartype total_number_of_updates_pending_install: int :ivar reboot_behavior: Indicates if updates are available and at least one of the updates needs - a reboot. Possible values include: "NeverReboots", "RequiresReboot", "RequestReboot". + a reboot. Known values are: "NeverReboots", "RequiresReboot", and "RequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.InstallRebootBehavior - :ivar ongoing_update_operation: The current update operation. Possible values include: "None", - "Scan", "Download", "Install". + :ivar ongoing_update_operation: The current update operation. Known values are: "None", "Scan", + "Download", and "Install". :vartype ongoing_update_operation: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateOperation :ivar in_progress_download_job_id: The job ID of the download job in progress. @@ -5204,62 +5705,80 @@ class UpdateSummary(ARMBaseModel): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_completed_download_job_date_time': {'readonly': True}, - 'last_completed_download_job_id': {'readonly': True}, - 'last_download_job_status': {'readonly': True}, - 'last_completed_install_job_date_time': {'readonly': True}, - 'last_completed_install_job_id': {'readonly': True}, - 'last_install_job_status': {'readonly': True}, - 'total_number_of_updates_available': {'readonly': True}, - 'total_number_of_updates_pending_download': {'readonly': True}, - 'total_number_of_updates_pending_install': {'readonly': True}, - 'reboot_behavior': {'readonly': True}, - 'ongoing_update_operation': {'readonly': True}, - 'in_progress_download_job_id': {'readonly': True}, - 'in_progress_install_job_id': {'readonly': True}, - 'in_progress_download_job_started_date_time': {'readonly': True}, - 'in_progress_install_job_started_date_time': {'readonly': True}, - 'update_titles': {'readonly': True}, - 'updates': {'readonly': True}, - 'total_update_size_in_bytes': {'readonly': True}, - 'total_time_in_minutes': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_completed_download_job_date_time": {"readonly": True}, + "last_completed_download_job_id": {"readonly": True}, + "last_download_job_status": {"readonly": True}, + "last_completed_install_job_date_time": {"readonly": True}, + "last_completed_install_job_id": {"readonly": True}, + "last_install_job_status": {"readonly": True}, + "total_number_of_updates_available": {"readonly": True}, + "total_number_of_updates_pending_download": {"readonly": True}, + "total_number_of_updates_pending_install": {"readonly": True}, + "reboot_behavior": {"readonly": True}, + "ongoing_update_operation": {"readonly": True}, + "in_progress_download_job_id": {"readonly": True}, + "in_progress_install_job_id": {"readonly": True}, + "in_progress_download_job_started_date_time": {"readonly": True}, + "in_progress_install_job_started_date_time": {"readonly": True}, + "update_titles": {"readonly": True}, + "updates": {"readonly": True}, + "total_update_size_in_bytes": {"readonly": True}, + "total_time_in_minutes": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'device_version_number': {'key': 'properties.deviceVersionNumber', 'type': 'str'}, - 'friendly_device_version_name': {'key': 'properties.friendlyDeviceVersionName', 'type': 'str'}, - 'device_last_scanned_date_time': {'key': 'properties.deviceLastScannedDateTime', 'type': 'iso-8601'}, - 'last_completed_scan_job_date_time': {'key': 'properties.lastCompletedScanJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_date_time': {'key': 'properties.lastCompletedDownloadJobDateTime', 'type': 'iso-8601'}, - 'last_completed_download_job_id': {'key': 'properties.lastCompletedDownloadJobId', 'type': 'str'}, - 'last_download_job_status': {'key': 'properties.lastDownloadJobStatus', 'type': 'str'}, - 'last_completed_install_job_date_time': {'key': 'properties.lastCompletedInstallJobDateTime', 'type': 'iso-8601'}, - 'last_completed_install_job_id': {'key': 'properties.lastCompletedInstallJobId', 'type': 'str'}, - 'last_install_job_status': {'key': 'properties.lastInstallJobStatus', 'type': 'str'}, - 'total_number_of_updates_available': {'key': 'properties.totalNumberOfUpdatesAvailable', 'type': 'int'}, - 'total_number_of_updates_pending_download': {'key': 'properties.totalNumberOfUpdatesPendingDownload', 'type': 'int'}, - 'total_number_of_updates_pending_install': {'key': 'properties.totalNumberOfUpdatesPendingInstall', 'type': 'int'}, - 'reboot_behavior': {'key': 'properties.rebootBehavior', 'type': 'str'}, - 'ongoing_update_operation': {'key': 'properties.ongoingUpdateOperation', 'type': 'str'}, - 'in_progress_download_job_id': {'key': 'properties.inProgressDownloadJobId', 'type': 'str'}, - 'in_progress_install_job_id': {'key': 'properties.inProgressInstallJobId', 'type': 'str'}, - 'in_progress_download_job_started_date_time': {'key': 'properties.inProgressDownloadJobStartedDateTime', 'type': 'iso-8601'}, - 'in_progress_install_job_started_date_time': {'key': 'properties.inProgressInstallJobStartedDateTime', 'type': 'iso-8601'}, - 'update_titles': {'key': 'properties.updateTitles', 'type': '[str]'}, - 'updates': {'key': 'properties.updates', 'type': '[UpdateDetails]'}, - 'total_update_size_in_bytes': {'key': 'properties.totalUpdateSizeInBytes', 'type': 'float'}, - 'total_time_in_minutes': {'key': 'properties.totalTimeInMinutes', 'type': 'int'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "device_version_number": {"key": "properties.deviceVersionNumber", "type": "str"}, + "friendly_device_version_name": {"key": "properties.friendlyDeviceVersionName", "type": "str"}, + "device_last_scanned_date_time": {"key": "properties.deviceLastScannedDateTime", "type": "iso-8601"}, + "last_completed_scan_job_date_time": {"key": "properties.lastCompletedScanJobDateTime", "type": "iso-8601"}, + "last_completed_download_job_date_time": { + "key": "properties.lastCompletedDownloadJobDateTime", + "type": "iso-8601", + }, + "last_completed_download_job_id": {"key": "properties.lastCompletedDownloadJobId", "type": "str"}, + "last_download_job_status": {"key": "properties.lastDownloadJobStatus", "type": "str"}, + "last_completed_install_job_date_time": { + "key": "properties.lastCompletedInstallJobDateTime", + "type": "iso-8601", + }, + "last_completed_install_job_id": {"key": "properties.lastCompletedInstallJobId", "type": "str"}, + "last_install_job_status": {"key": "properties.lastInstallJobStatus", "type": "str"}, + "total_number_of_updates_available": {"key": "properties.totalNumberOfUpdatesAvailable", "type": "int"}, + "total_number_of_updates_pending_download": { + "key": "properties.totalNumberOfUpdatesPendingDownload", + "type": "int", + }, + "total_number_of_updates_pending_install": { + "key": "properties.totalNumberOfUpdatesPendingInstall", + "type": "int", + }, + "reboot_behavior": {"key": "properties.rebootBehavior", "type": "str"}, + "ongoing_update_operation": {"key": "properties.ongoingUpdateOperation", "type": "str"}, + "in_progress_download_job_id": {"key": "properties.inProgressDownloadJobId", "type": "str"}, + "in_progress_install_job_id": {"key": "properties.inProgressInstallJobId", "type": "str"}, + "in_progress_download_job_started_date_time": { + "key": "properties.inProgressDownloadJobStartedDateTime", + "type": "iso-8601", + }, + "in_progress_install_job_started_date_time": { + "key": "properties.inProgressInstallJobStartedDateTime", + "type": "iso-8601", + }, + "update_titles": {"key": "properties.updateTitles", "type": "[str]"}, + "updates": {"key": "properties.updates", "type": "[UpdateDetails]"}, + "total_update_size_in_bytes": {"key": "properties.totalUpdateSizeInBytes", "type": "float"}, + "total_time_in_minutes": {"key": "properties.totalTimeInMinutes", "type": "int"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, device_version_number: Optional[str] = None, @@ -5268,7 +5787,18 @@ def __init__( last_completed_scan_job_date_time: Optional[datetime.datetime] = None, **kwargs ): - super(UpdateSummary, self).__init__(**kwargs) + """ + :keyword device_version_number: The current version of the device in format: 1.2.17312.13.",. + :paramtype device_version_number: str + :keyword friendly_device_version_name: The current version of the device in text format. + :paramtype friendly_device_version_name: str + :keyword device_last_scanned_date_time: The last time when a scan was done on the device. + :paramtype device_last_scanned_date_time: ~datetime.datetime + :keyword last_completed_scan_job_date_time: The time when the last scan job was completed + (success/cancelled/failed) on the appliance. + :paramtype last_completed_scan_job_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) self.system_data = None self.device_version_number = device_version_number self.friendly_device_version_name = friendly_device_version_name @@ -5295,48 +5825,57 @@ def __init__( self.total_time_in_minutes = None -class UploadCertificateRequest(msrest.serialization.Model): +class UploadCertificateRequest(_serialization.Model): """The upload certificate request. All required parameters must be populated in order to send to Azure. - :param authentication_type: The authentication type. Possible values include: "Invalid", + :ivar authentication_type: The authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type authentication_type: str or + :vartype authentication_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AuthenticationType - :param certificate: Required. The base64 encoded certificate raw data. - :type certificate: str + :ivar certificate: The base64 encoded certificate raw data. Required. + :vartype certificate: str """ _validation = { - 'certificate': {'required': True}, + "certificate": {"required": True}, } _attribute_map = { - 'authentication_type': {'key': 'properties.authenticationType', 'type': 'str'}, - 'certificate': {'key': 'properties.certificate', 'type': 'str'}, + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "certificate": {"key": "properties.certificate", "type": "str"}, } def __init__( self, *, certificate: str, - authentication_type: Optional[Union[str, "AuthenticationType"]] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs ): - super(UploadCertificateRequest, self).__init__(**kwargs) + """ + :keyword authentication_type: The authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype authentication_type: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AuthenticationType + :keyword certificate: The base64 encoded certificate raw data. Required. + :paramtype certificate: str + """ + super().__init__(**kwargs) self.authentication_type = authentication_type self.certificate = certificate -class UploadCertificateResponse(msrest.serialization.Model): +class UploadCertificateResponse(_serialization.Model): """The upload registration certificate response. Variables are only populated by the server, and will be ignored when sending a request. - :param auth_type: Specifies authentication type. Possible values include: "Invalid", + :ivar auth_type: Specifies authentication type. Known values are: "Invalid" and "AzureActiveDirectory". - :type auth_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AuthenticationType + :vartype auth_type: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AuthenticationType :ivar resource_id: The resource ID of the Data Box Edge/Gateway device. :vartype resource_id: str :ivar aad_authority: Azure Active Directory tenant authority. @@ -5355,33 +5894,34 @@ class UploadCertificateResponse(msrest.serialization.Model): """ _validation = { - 'resource_id': {'readonly': True}, - 'aad_authority': {'readonly': True}, - 'aad_tenant_id': {'readonly': True}, - 'service_principal_client_id': {'readonly': True}, - 'service_principal_object_id': {'readonly': True}, - 'azure_management_endpoint_audience': {'readonly': True}, - 'aad_audience': {'readonly': True}, + "resource_id": {"readonly": True}, + "aad_authority": {"readonly": True}, + "aad_tenant_id": {"readonly": True}, + "service_principal_client_id": {"readonly": True}, + "service_principal_object_id": {"readonly": True}, + "azure_management_endpoint_audience": {"readonly": True}, + "aad_audience": {"readonly": True}, } _attribute_map = { - 'auth_type': {'key': 'authType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'aad_authority': {'key': 'aadAuthority', 'type': 'str'}, - 'aad_tenant_id': {'key': 'aadTenantId', 'type': 'str'}, - 'service_principal_client_id': {'key': 'servicePrincipalClientId', 'type': 'str'}, - 'service_principal_object_id': {'key': 'servicePrincipalObjectId', 'type': 'str'}, - 'azure_management_endpoint_audience': {'key': 'azureManagementEndpointAudience', 'type': 'str'}, - 'aad_audience': {'key': 'aadAudience', 'type': 'str'}, - } - - def __init__( - self, - *, - auth_type: Optional[Union[str, "AuthenticationType"]] = None, - **kwargs - ): - super(UploadCertificateResponse, self).__init__(**kwargs) + "auth_type": {"key": "authType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "aad_authority": {"key": "aadAuthority", "type": "str"}, + "aad_tenant_id": {"key": "aadTenantId", "type": "str"}, + "service_principal_client_id": {"key": "servicePrincipalClientId", "type": "str"}, + "service_principal_object_id": {"key": "servicePrincipalObjectId", "type": "str"}, + "azure_management_endpoint_audience": {"key": "azureManagementEndpointAudience", "type": "str"}, + "aad_audience": {"key": "aadAudience", "type": "str"}, + } + + def __init__(self, *, auth_type: Optional[Union[str, "_models.AuthenticationType"]] = None, **kwargs): + """ + :keyword auth_type: Specifies authentication type. Known values are: "Invalid" and + "AzureActiveDirectory". + :paramtype auth_type: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AuthenticationType + """ + super().__init__(**kwargs) self.auth_type = auth_type self.resource_id = None self.aad_authority = None @@ -5405,84 +5945,93 @@ class User(ARMBaseModel): :vartype type: str :ivar system_data: User in DataBoxEdge Resource. :vartype system_data: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SystemData - :param encrypted_password: The password details. - :type encrypted_password: + :ivar encrypted_password: The password details. + :vartype encrypted_password: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret :ivar share_access_rights: List of shares that the user has rights on. This field should not be specified during user creation. :vartype share_access_rights: list[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessRight] - :param user_type: Type of the user. Possible values include: "Share", "LocalManagement", "ARM". - :type user_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UserType + :ivar user_type: Type of the user. Known values are: "Share", "LocalManagement", and "ARM". + :vartype user_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UserType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'share_access_rights': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "share_access_rights": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'encrypted_password': {'key': 'properties.encryptedPassword', 'type': 'AsymmetricEncryptedSecret'}, - 'share_access_rights': {'key': 'properties.shareAccessRights', 'type': '[ShareAccessRight]'}, - 'user_type': {'key': 'properties.userType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "encrypted_password": {"key": "properties.encryptedPassword", "type": "AsymmetricEncryptedSecret"}, + "share_access_rights": {"key": "properties.shareAccessRights", "type": "[ShareAccessRight]"}, + "user_type": {"key": "properties.userType", "type": "str"}, } def __init__( self, *, - encrypted_password: Optional["AsymmetricEncryptedSecret"] = None, - user_type: Optional[Union[str, "UserType"]] = None, + encrypted_password: Optional["_models.AsymmetricEncryptedSecret"] = None, + user_type: Optional[Union[str, "_models.UserType"]] = None, **kwargs ): - super(User, self).__init__(**kwargs) + """ + :keyword encrypted_password: The password details. + :paramtype encrypted_password: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.AsymmetricEncryptedSecret + :keyword user_type: Type of the user. Known values are: "Share", "LocalManagement", and "ARM". + :paramtype user_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UserType + """ + super().__init__(**kwargs) self.system_data = None self.encrypted_password = encrypted_password self.share_access_rights = None self.user_type = user_type -class UserAccessRight(msrest.serialization.Model): +class UserAccessRight(_serialization.Model): """The mapping between a particular user and the access type on the SMB share. All required parameters must be populated in order to send to Azure. - :param user_id: Required. User ID (already existing in the device). - :type user_id: str - :param access_type: Required. Type of access to be allowed for the user. Possible values - include: "Change", "Read", "Custom". - :type access_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessType + :ivar user_id: User ID (already existing in the device). Required. + :vartype user_id: str + :ivar access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :vartype access_type: str or ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessType """ _validation = { - 'user_id': {'required': True}, - 'access_type': {'required': True}, + "user_id": {"required": True}, + "access_type": {"required": True}, } _attribute_map = { - 'user_id': {'key': 'userId', 'type': 'str'}, - 'access_type': {'key': 'accessType', 'type': 'str'}, - } - - def __init__( - self, - *, - user_id: str, - access_type: Union[str, "ShareAccessType"], - **kwargs - ): - super(UserAccessRight, self).__init__(**kwargs) + "user_id": {"key": "userId", "type": "str"}, + "access_type": {"key": "accessType", "type": "str"}, + } + + def __init__(self, *, user_id: str, access_type: Union[str, "_models.ShareAccessType"], **kwargs): + """ + :keyword user_id: User ID (already existing in the device). Required. + :paramtype user_id: str + :keyword access_type: Type of access to be allowed for the user. Required. Known values are: + "Change", "Read", and "Custom". + :paramtype access_type: str or + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareAccessType + """ + super().__init__(**kwargs) self.user_id = user_id self.access_type = access_type -class UserList(msrest.serialization.Model): +class UserList(_serialization.Model): """Collection of users. Variables are only populated by the server, and will be ignored when sending a request. @@ -5494,19 +6043,17 @@ class UserList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[User]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[User]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(UserList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/__init__.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/__init__.py index d70057be6458..febac852eb27 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/__init__.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/__init__.py @@ -25,23 +25,29 @@ from ._triggers_operations import TriggersOperations from ._users_operations import UsersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'AvailableSkusOperations', - 'DevicesOperations', - 'AlertsOperations', - 'BandwidthSchedulesOperations', - 'JobsOperations', - 'NodesOperations', - 'OperationsStatusOperations', - 'OrdersOperations', - 'RolesOperations', - 'AddonsOperations', - 'MonitoringConfigOperations', - 'SharesOperations', - 'StorageAccountCredentialsOperations', - 'StorageAccountsOperations', - 'ContainersOperations', - 'TriggersOperations', - 'UsersOperations', + "Operations", + "AvailableSkusOperations", + "DevicesOperations", + "AlertsOperations", + "BandwidthSchedulesOperations", + "JobsOperations", + "NodesOperations", + "OperationsStatusOperations", + "OrdersOperations", + "RolesOperations", + "AddonsOperations", + "MonitoringConfigOperations", + "SharesOperations", + "StorageAccountCredentialsOperations", + "StorageAccountsOperations", + "ContainersOperations", + "TriggersOperations", + "UsersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_addons_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_addons_operations.py index 2c92a13640b4..faf2707f81a7 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_addons_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,114 +6,284 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_role_request( + device_name: str, role_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, addon_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, addon_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) + + +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AddonsOperations(object): - """AddonsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`addons` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_role( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AddonList"] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Addon"]: """Lists all the addons configured in the role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AddonList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.AddonList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_role.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_role_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_role.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,122 +292,137 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_role.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons" + } + @distributed_trace def get( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Addon" + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Addon: """Gets a specific addon by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } def _create_or_update_initial( self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Addon"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Addon"]] + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> Optional[_models.Addon]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(addon, 'Addon') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Addon]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -245,53 +431,145 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Addon"] + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: """Create or update a addon. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param addon: The addon properties. + :param addon: The addon properties. Required. :type addon: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Addon or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Required. + :type addon: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + role_name: str, + addon_name: str, + resource_group_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param addon_name: The addon name. Required. + :type addon_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param addon: The addon properties. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Addon] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -299,80 +577,77 @@ def begin_create_or_update( addon_name=addon_name, resource_group_name=resource_group_name, addon=addon, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + addon_name=addon_name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -382,79 +657,81 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - role_name, # type: str - addon_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, role_name: str, addon_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the addon on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param addon_name: The addon name. + :param addon_name: The addon name. Required. :type addon_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, addon_name=addon_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/addons/{addonName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_alerts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_alerts_operations.py index aa5e57d65099..f726353f54b6 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_alerts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_alerts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,204 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class AlertsOperations(object): - """AlertsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_by_data_box_edge_device_request( + device_name: str, 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 {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 AlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Alert"]: """Gets all the alerts for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Alert or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Alert] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertList', pipeline_response) + deserialized = self._deserialize("AlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,72 +212,75 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts'} # type: ignore - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Alert: """Gets an alert by name. Gets an alert by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The alert name. + :param name: The alert name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) + :return: Alert or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Alert', pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/alerts/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_available_skus_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_available_skus_operations.py index 33646794cd4a..5a544cc44581 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_available_skus_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_available_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,158 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } -class AvailableSkusOperations(object): - """AvailableSkusOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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 AvailableSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`available_skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeSkuList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.DataBoxEdgeSku"]: """List all the available Skus and information related to them. List all the available Skus and information related to them. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeSkuList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeSkuList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeSku or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeSkuList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeSkuList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeSkuList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeSkuList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,7 +166,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/availableSkus"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_bandwidth_schedules_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_bandwidth_schedules_operations.py index 3d4f49fbe32a..fa833c401e79 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_bandwidth_schedules_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_bandwidth_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,278 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class BandwidthSchedulesOperations(object): - """BandwidthSchedulesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class BandwidthSchedulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`bandwidth_schedules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BandwidthSchedulesList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 BandwidthSchedulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedulesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedulesList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BandwidthSchedulesList', pipeline_response) + deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +286,130 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BandwidthSchedule" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BandwidthSchedule, or the result of cls(response) + :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BandwidthSchedule"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BandwidthSchedule"]] + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> Optional[_models.BandwidthSchedule]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BandwidthSchedule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BandwidthSchedule") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +418,219 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.BandwidthSchedule" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BandwidthSchedule"] + device_name: str, + name: str, + resource_group_name: str, + parameters: _models.BandwidthSchedule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name which needs to be added/updated. + :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The bandwidth schedule to be added or updated. + :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BandwidthSchedule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BandwidthSchedule"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + parameters: Union[_models.BandwidthSchedule, IO], + **kwargs: Any + ) -> LROPoller[_models.BandwidthSchedule]: + """Creates or updates a bandwidth schedule. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The bandwidth schedule name which needs to be added/updated. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The bandwidth schedule to be added or updated. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BandwidthSchedule or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.BandwidthSchedule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BandwidthSchedule', pipeline_response) - + deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +640,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified bandwidth schedule. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The bandwidth schedule name. + :param name: The bandwidth schedule name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_containers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_containers_operations.py index 82bffe37fd93..7adfeb8b767b 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_containers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,342 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_storage_account_request( + device_name: str, storage_account_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, + storage_account_name: str, + container_name: str, + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "containerName": _SERIALIZER.url("container_name", container_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 ContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ContainersOperations(object): - """ContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_storage_account( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ContainerList"] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Container"]: """Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. Lists all the containers of a storage Account in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage Account name. + :param storage_account_name: The storage Account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ContainerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ContainerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Container or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.ContainerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_storage_account.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_storage_account_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ContainerList', pipeline_response) + deserialized = self._deserialize("ContainerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,124 +350,139 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_storage_account.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers" + } + + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Container" + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.Container: """Gets a container by name. Gets a container by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container Name. + :param container_name: The container Name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Container, or the result of cls(response) + :return: Container or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Container"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Container"]] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> Optional[_models.Container]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(container, 'Container') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Container]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container, (IO, bytes)): + _content = container + else: + _json = self._serialize.body(container, "Container") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -249,55 +491,154 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Container', pipeline_response) + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - container, # type: "_models.Container" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Container"] + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: _models.Container, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: """Creates a new container or updates an existing container on the device. Creates a new container or updates an existing container on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param container: The container properties. + :param container: The container properties. Required. :type container: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Container or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Container"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Required. + :type container: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + container_name: str, + resource_group_name: str, + container: Union[_models.Container, IO], + **kwargs: Any + ) -> LROPoller[_models.Container]: + """Creates a new container or updates an existing container on the device. + + Creates a new container or updates an existing container on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The Storage Account Name. Required. + :type storage_account_name: str + :param container_name: The container name. Required. + :type container_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param container: The container properties. Is either a model type or a IO type. Required. + :type container: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Container or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Container] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Container] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, @@ -305,80 +646,77 @@ def begin_create_or_update( container_name=container_name, resource_group_name=resource_group_name, container=container, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Container', pipeline_response) - + deserialized = self._deserialize("Container", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -388,121 +726,120 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the container on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + storage_account_name=storage_account_name, + container_name=container_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -512,81 +849,81 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } + @distributed_trace def begin_refresh( - self, - device_name, # type: str - storage_account_name, # type: str - container_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, container_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Refreshes the container metadata with the data from the cloud. Refreshes the container metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The Storage Account Name. + :param storage_account_name: The Storage Account Name. Required. :type storage_account_name: str - :param container_name: The container name. + :param container_name: The container name. Required. :type container_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, container_name=container_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'containerName': self._serialize.url("container_name", container_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}/containers/{containerName}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_devices_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_devices_operations.py index bbb4d75c968e..b2655bff0819 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_devices_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_devices_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,680 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_list_by_subscription_request( + subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "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, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices", + ) # 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"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_update_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_download_updates_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_generate_certificate_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_extended_information_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -class DevicesOperations(object): - """DevicesOperations operations. +def build_install_updates_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_get_network_settings_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_scan_for_updates_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_create_or_update_security_settings_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_update_extended_information_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_get_update_summary_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_upload_certificate_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +class DevicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`devices` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_subscription( - self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a subscription. :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,75 +688,92 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace def list_by_resource_group( - self, - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataBoxEdgeDeviceList"] + self, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.DataBoxEdgeDevice"]: """Gets all the Data Box Edge/Data Box Gateway devices in a resource group. - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataBoxEdgeDeviceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataBoxEdgeDevice or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDeviceList', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,230 +782,335 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DataBoxEdgeDevice: """Gets the properties of the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } def _create_or_update_initial( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(data_box_edge_device, 'DataBoxEdgeDevice') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_box_edge_device, (IO, bytes)): + _content = data_box_edge_device + else: + _json = self._serialize.body(data_box_edge_device, "DataBoxEdgeDevice") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: _models.DataBoxEdgeDevice, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - data_box_edge_device, # type: "_models.DataBoxEdgeDevice" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DataBoxEdgeDevice"] + device_name: str, + resource_group_name: str, + data_box_edge_device: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: """Creates or updates a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param data_box_edge_device: The resource object. - :type data_box_edge_device: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice + :param data_box_edge_device: The resource object. Required. + :type data_box_edge_device: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + data_box_edge_device: Union[_models.DataBoxEdgeDevice, IO], + **kwargs: Any + ) -> LROPoller[_models.DataBoxEdgeDevice]: + """Creates or updates a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param data_box_edge_device: The resource object. Is either a model type or a IO type. + Required. + :type data_box_edge_device: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataBoxEdgeDevice or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, data_box_edge_device=data_box_edge_device, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) - + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -425,174 +1120,250 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + @overload def update( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDevicePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDevice" + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDevicePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: """Modifies a Data Box Edge/Data Box Gateway resource. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The resource parameters. + :param parameters: The resource parameters. Required. :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevicePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDevicePatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDevice: + """Modifies a Data Box Edge/Data Box Gateway resource. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The resource parameters. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevicePatch or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDevice, or the result of cls(response) + :return: DataBoxEdgeDevice or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDevice - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDevice"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDevicePatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDevice] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDevicePatch") + + request = build_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDevice', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDevice", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}'} # type: ignore - def _download_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}" + } + + def _download_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._download_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_download_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._download_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -602,227 +1373,240 @@ def _download_updates_initial( if cls: return cls(pipeline_response, None, {}) - _download_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + _download_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } - def begin_download_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_download_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Downloads the updates on a Data Box Edge/Data Box Gateway device. Downloads the updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._download_updates_initial( + raw_result = self._download_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_download_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_download_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/downloadUpdates" + } + + @distributed_trace def generate_certificate( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GenerateCertResponse" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.GenerateCertResponse: """Generates certificate for activation key. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GenerateCertResponse, or the result of cls(response) + :return: GenerateCertResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.GenerateCertResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateCertResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.generate_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.GenerateCertResponse] = kwargs.pop("cls", None) + + request = build_generate_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.generate_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GenerateCertResponse', pipeline_response) + deserialized = self._deserialize("GenerateCertResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate'} # type: ignore + generate_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/generateCertificate" + } + + @distributed_trace def get_extended_information( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Azure Stack Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + request = build_get_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation'} # type: ignore - def _install_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/getExtendedInformation" + } + + def _install_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._install_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_install_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._install_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -832,168 +1616,176 @@ def _install_updates_initial( if cls: return cls(pipeline_response, None, {}) - _install_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + _install_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } - def begin_install_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_install_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Installs the updates on the Data Box Edge/Data Box Gateway device. Installs the updates on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._install_updates_initial( + raw_result = self._install_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_install_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_install_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/installUpdates" + } + @distributed_trace def get_network_settings( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.NetworkSettings" + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.NetworkSettings: """Gets the network settings of the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkSettings, or the result of cls(response) + :return: NetworkSettings or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.NetworkSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_network_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.NetworkSettings] = kwargs.pop("cls", None) + + request = build_get_network_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkSettings', pipeline_response) + deserialized = self._deserialize("NetworkSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_network_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default'} # type: ignore - def _scan_for_updates_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_network_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/networkSettings/default" + } + + def _scan_for_updates_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._scan_for_updates_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_scan_for_updates_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._scan_for_updates_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1003,115 +1795,128 @@ def _scan_for_updates_initial( if cls: return cls(pipeline_response, None, {}) - _scan_for_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + _scan_for_updates_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } - def begin_scan_for_updates( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_scan_for_updates(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Scans for updates on a Data Box Edge/Data Box Gateway device. Scans for updates on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._scan_for_updates_initial( + raw_result = self._scan_for_updates_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_scan_for_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _create_or_update_security_settings_initial( + begin_scan_for_updates.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/scanForUpdates" + } + + def _create_or_update_security_settings_initial( # pylint: disable=inconsistent-return-statements self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_security_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_settings, 'SecuritySettings') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_settings, (IO, bytes)): + _content = security_settings + else: + _json = self._serialize.body(security_settings, "SecuritySettings") + + request = build_create_or_update_security_settings_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_security_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1121,269 +1926,502 @@ def _create_or_update_security_settings_initial( if cls: return cls(pipeline_response, None, {}) - _create_or_update_security_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + _create_or_update_security_settings_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + @overload def begin_create_or_update_security_settings( self, - device_name, # type: str - resource_group_name, # type: str - security_settings, # type: "_models.SecuritySettings" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + device_name: str, + resource_group_name: str, + security_settings: _models.SecuritySettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the security settings on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param security_settings: The security settings. + :param security_settings: The security settings. Required. :type security_settings: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SecuritySettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @overload + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Required. + :type security_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update_security_settings( + self, + device_name: str, + resource_group_name: str, + security_settings: Union[_models.SecuritySettings, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the security settings on a Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param security_settings: The security settings. Is either a model type or a IO type. Required. + :type security_settings: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.SecuritySettings or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_security_settings_initial( + raw_result = self._create_or_update_security_settings_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, security_settings=security_settings, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_security_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update_security_settings.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/securitySettings/default/update" + } + + @overload + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: _models.DataBoxEdgeDeviceExtendedInfoPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Required. + :type parameters: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload def update_extended_information( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.DataBoxEdgeDeviceExtendedInfoPatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.DataBoxEdgeDeviceExtendedInfo" + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: """Gets additional information for the specified Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The patch object. - :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch + :param parameters: The patch object. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataBoxEdgeDeviceExtendedInfo, or the result of cls(response) + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_extended_information( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.DataBoxEdgeDeviceExtendedInfoPatch, IO], + **kwargs: Any + ) -> _models.DataBoxEdgeDeviceExtendedInfo: + """Gets additional information for the specified Data Box Edge/Data Box Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The patch object. Is either a model type or a IO type. Required. + :type parameters: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfoPatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataBoxEdgeDeviceExtendedInfo or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DataBoxEdgeDeviceExtendedInfo + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataBoxEdgeDeviceExtendedInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_extended_information.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DataBoxEdgeDeviceExtendedInfoPatch') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataBoxEdgeDeviceExtendedInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataBoxEdgeDeviceExtendedInfoPatch") + + request = build_update_extended_information_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_extended_information.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataBoxEdgeDeviceExtendedInfo', pipeline_response) + deserialized = self._deserialize("DataBoxEdgeDeviceExtendedInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update_extended_information.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation'} # type: ignore - def get_update_summary( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UpdateSummary" - """Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. + update_extended_information.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateExtendedInformation" + } + + @distributed_trace + def get_update_summary(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.UpdateSummary: + """Gets information about the availability of updates based on the last scan of the device. It + also gets information about any ongoing download or install jobs on the device. Gets information about the availability of updates based on the last scan of the device. It also gets information about any ongoing download or install jobs on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UpdateSummary, or the result of cls(response) + :return: UpdateSummary or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UpdateSummary - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateSummary"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_update_summary.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.UpdateSummary] = kwargs.pop("cls", None) + + request = build_get_update_summary_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_summary.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UpdateSummary', pipeline_response) + deserialized = self._deserialize("UpdateSummary", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_update_summary.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default'} # type: ignore + get_update_summary.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/updateSummary/default" + } + + @overload def upload_certificate( self, - device_name, # type: str - resource_group_name, # type: str - parameters, # type: "_models.UploadCertificateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.UploadCertificateResponse" + device_name: str, + resource_group_name: str, + parameters: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: """Uploads registration certificate for the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param parameters: The upload certificate request. + :param parameters: The upload certificate request. Required. :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UploadCertificateResponse, or the result of cls(response) + :return: UploadCertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def upload_certificate( + self, + device_name: str, + resource_group_name: str, + parameters: Union[_models.UploadCertificateRequest, IO], + **kwargs: Any + ) -> _models.UploadCertificateResponse: + """Uploads registration certificate for the device. + + :param device_name: The device name. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param parameters: The upload certificate request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateRequest + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UploadCertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.UploadCertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UploadCertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.upload_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UploadCertificateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UploadCertificateResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UploadCertificateRequest") + + request = build_upload_certificate_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.upload_certificate.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('UploadCertificateResponse', pipeline_response) + deserialized = self._deserialize("UploadCertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - upload_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate'} # type: ignore + + upload_certificate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/uploadCertificate" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_jobs_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_jobs_operations.py index 1fa2b0e1ad23..70eebe4db0c4 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_jobs_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_jobs_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class JobsOperations(object): - """JobsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class JobsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`jobs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/jobs/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_monitoring_config_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_monitoring_config_operations.py index dc3a756ee375..170478b25985 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_monitoring_config_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_monitoring_config_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,285 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + device_name: str, role_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, role_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, role_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, role_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class MonitoringConfigOperations(object): - """MonitoringConfigOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class MonitoringConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`monitoring_config` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MonitoringMetricConfigurationList"] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.MonitoringMetricConfiguration"]: """Lists metric configurations in a role. Lists metric configurations in a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 MonitoringMetricConfigurationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfigurationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MonitoringMetricConfiguration or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfigurationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.MonitoringMetricConfigurationList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfigurationList', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfigurationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,118 +293,134 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig" + } + + @distributed_trace def get( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MonitoringMetricConfiguration" + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.MonitoringMetricConfiguration: """Gets a metric configuration of a role. Gets a metric configuration of a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MonitoringMetricConfiguration, or the result of cls(response) + :return: MonitoringMetricConfiguration or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } def _create_or_update_initial( self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - monitoring_metric_configuration, # type: "_models.MonitoringMetricConfiguration" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MonitoringMetricConfiguration"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MonitoringMetricConfiguration"]] + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> Optional[_models.MonitoringMetricConfiguration]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(monitoring_metric_configuration, 'MonitoringMetricConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.MonitoringMetricConfiguration]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(monitoring_metric_configuration, (IO, bytes)): + _content = monitoring_metric_configuration + else: + _json = self._serialize.body(monitoring_metric_configuration, "MonitoringMetricConfiguration") + + request = build_create_or_update_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -243,129 +429,227 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: _models.MonitoringMetricConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: + """Creates a new metric configuration or updates an existing one for a role. + + Creates a new metric configuration or updates an existing one for a role. + + :param device_name: The device name. Required. + :type device_name: str + :param role_name: The role name. Required. + :type role_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param monitoring_metric_configuration: The metric configuration. Required. + :type monitoring_metric_configuration: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace def begin_create_or_update( self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - monitoring_metric_configuration, # type: "_models.MonitoringMetricConfiguration" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MonitoringMetricConfiguration"] + device_name: str, + role_name: str, + resource_group_name: str, + monitoring_metric_configuration: Union[_models.MonitoringMetricConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.MonitoringMetricConfiguration]: """Creates a new metric configuration or updates an existing one for a role. Creates a new metric configuration or updates an existing one for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param monitoring_metric_configuration: The metric configuration. - :type monitoring_metric_configuration: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration + :param monitoring_metric_configuration: The metric configuration. Is either a model type or a + IO type. Required. + :type monitoring_metric_configuration: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either MonitoringMetricConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.MonitoringMetricConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringMetricConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MonitoringMetricConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, monitoring_metric_configuration=monitoring_metric_configuration, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MonitoringMetricConfiguration', pipeline_response) - + deserialized = self._deserialize("MonitoringMetricConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + role_name=role_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -375,76 +659,78 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - role_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, role_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """deletes a new metric configuration for a role. deletes a new metric configuration for a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param role_name: The role name. + :param role_name: The role name. Required. :type role_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, role_name=role_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{roleName}/monitoringConfig/default" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_nodes_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_nodes_operations.py index fdddca8309c8..66f2e8466dc0 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_nodes_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_nodes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,108 +6,170 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class NodesOperations(object): - """NodesOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.NodeList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Node"]: """Gets all the nodes currently configured under this Data Box Edge device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 NodeList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.NodeList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Node or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Node] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NodeList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.NodeList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('NodeList', pipeline_response) + deserialized = self._deserialize("NodeList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +178,8 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/nodes" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_operations.py index 046e4bc51513..67583a99e943 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,152 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DataBoxEdge/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + 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 list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List all the supported operations. List all the supported operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.OperationsList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +160,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.DataBoxEdge/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.DataBoxEdge/operations"} diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_operations_status_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_operations_status_operations.py index e670f8a84b7d..3559eb6e0d62 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_operations_status_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_operations_status_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +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( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class OperationsStatusOperations(object): - """OperationsStatusOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class OperationsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`operations_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Job" + 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, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Job: """Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. Gets the details of a specified job on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The job name. + :param name: The job name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Job, or the result of cls(response) + :return: Job or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Job - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Job"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Job] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Job', pipeline_response) + deserialized = self._deserialize("Job", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/operationsStatus/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_orders_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_orders_operations.py index 7d118289e192..5d74127b58bb 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_orders_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_orders_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,307 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request(device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore -class OrdersOperations(object): - """OrdersOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_dc_access_code_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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 OrdersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`orders` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OrderList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Order"]: """Lists all the orders related to a Data Box Edge/Data Box Gateway device. Lists all the orders related to a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 OrderList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.OrderList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Order or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OrderList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.OrderList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OrderList', pipeline_response) + deserialized = self._deserialize("OrderList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,112 +315,123 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Order" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders" + } + + @distributed_trace + def get(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.Order: """Gets a specific order by name. Gets a specific order by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Order, or the result of cls(response) + :return: Order or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } def _create_or_update_initial( - self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Order"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Order"]] + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> Optional[_models.Order]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(order, 'Order') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Order]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(order, (IO, bytes)): + _content = order + else: + _json = self._serialize.body(order, "Order") + + request = build_create_or_update_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -233,122 +440,204 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Order', pipeline_response) + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - resource_group_name, # type: str - order, # type: "_models.Order" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Order"] + device_name: str, + resource_group_name: str, + order: _models.Order, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: """Creates or updates an order. Creates or updates an order. - :param device_name: The order details of a device. + :param device_name: The order details of a device. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param order: The order to be created or updated. + :param order: The order to be created or updated. Required. :type order: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Order or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Order"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @overload + def begin_create_or_update( + self, + device_name: str, + resource_group_name: str, + order: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Required. + :type order: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, resource_group_name: str, order: Union[_models.Order, IO], **kwargs: Any + ) -> LROPoller[_models.Order]: + """Creates or updates an order. + + Creates or updates an order. + + :param device_name: The order details of a device. Required. + :type device_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param order: The order to be created or updated. Is either a model type or a IO type. + Required. + :type order: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Order or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Order] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Order] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, resource_group_name=resource_group_name, order=order, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Order', pipeline_response) - + deserialized = self._deserialize("Order", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -358,132 +647,137 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } - def begin_delete( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the order related to the device. Deletes the order related to the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def list_dc_access_code( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DCAccessCode" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default" + } + + @distributed_trace + def list_dc_access_code(self, device_name: str, resource_group_name: str, **kwargs: Any) -> _models.DCAccessCode: """Gets the DCAccess Code. Gets the DCAccess Code. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DCAccessCode, or the result of cls(response) + :return: DCAccessCode or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.DCAccessCode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DCAccessCode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_dc_access_code.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.DCAccessCode] = kwargs.pop("cls", None) + + request = build_list_dc_access_code_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dc_access_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DCAccessCode', pipeline_response) + deserialized = self._deserialize("DCAccessCode", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_dc_access_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode'} # type: ignore + + list_dc_access_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/orders/default/listDCAccessCode" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_patch.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_roles_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_roles_operations.py index 252a36cf677a..ddc8857b6448 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_roles_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_roles_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,110 +6,277 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RolesOperations(object): - """RolesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class RolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Role"]: """Lists all the roles configured in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 RoleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.RoleList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Role or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.RoleList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleList', pipeline_response) + deserialized = self._deserialize("RoleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,116 +285,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Role" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Role: """Gets a specific role by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Role, or the result of cls(response) + :return: Role or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Role"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> Optional[_models.Role]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role, 'Role') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Role]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(role, (IO, bytes)): + _content = role + else: + _json = self._serialize.body(role, "Role") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -235,127 +412,207 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Role', pipeline_response) + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - role, # type: "_models.Role" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Role"] + device_name: str, + name: str, + resource_group_name: str, + role: _models.Role, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: """Create or update a role. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param role: The role properties. + :param role: The role properties. Required. :type role: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + role: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Required. + :type role: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, role: Union[_models.Role, IO], **kwargs: Any + ) -> LROPoller[_models.Role]: + """Create or update a role. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The role name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param role: The role properties. Is either a model type or a IO type. Required. + :type role: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Role or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Role] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Role] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, role=role, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Role', pipeline_response) - + deserialized = self._deserialize("Role", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -365,74 +622,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the role on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The role name. + :param name: The role name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/roles/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_shares_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_shares_operations.py index f1a4686a42d2..2d7c79e58570 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_shares_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,313 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_refresh_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -class SharesOperations(object): - """SharesOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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 SharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ShareList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.Share"]: """Lists all the shares in a Data Box Edge/Data Box Gateway device. Lists all the shares in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 ShareList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.ShareList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Share or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ShareList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.ShareList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ShareList', pipeline_response) + deserialized = self._deserialize("ShareList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +321,127 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Share" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Share: """Gets a share by name. Gets a share by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Share, or the result of cls(response) + :return: Share or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Share"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Share"]] + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> Optional[_models.Share]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(share, 'Share') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Share]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share, (IO, bytes)): + _content = share + else: + _json = self._serialize.body(share, "Share") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +450,213 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Share', pipeline_response) + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - share, # type: "_models.Share" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Share"] + device_name: str, + name: str, + resource_group_name: str, + share: _models.Share, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: """Creates a new share or updates an existing share on the device. Creates a new share or updates an existing share on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param share: The share properties. + :param share: The share properties. Required. :type share: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Required. + :type share: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Share or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, share: Union[_models.Share, IO], **kwargs: Any + ) -> LROPoller[_models.Share]: + """Creates a new share or updates an existing share on the device. + + Creates a new share or updates an existing share on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The share name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param share: The share properties. Is either a model type or a IO type. Required. + :type share: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Share or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Share] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Share"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Share] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, share=share, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Share', pipeline_response) - + deserialized = self._deserialize("Share", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,114 +666,114 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the share on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}" + } + + def _refresh_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._refresh_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -488,76 +783,76 @@ def _refresh_initial( if cls: return cls(pipeline_response, None, {}) - _refresh_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + _refresh_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } - def begin_refresh( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_refresh(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Refreshes the share metadata with the data from the cloud. Refreshes the share metadata with the data from the cloud. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The share name. + :param name: The share name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/shares/{name}/refresh" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_storage_account_credentials_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_storage_account_credentials_operations.py index 5ebf92945344..132cd5493919 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_storage_account_credentials_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_storage_account_credentials_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,281 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class StorageAccountCredentialsOperations(object): - """StorageAccountCredentialsOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class StorageAccountCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`storage_account_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountCredentialList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccountCredential"]: """Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. Gets all the storage account credentials in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountCredentialList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredentialList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredentialList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.StorageAccountCredentialList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountCredentialList', pipeline_response) + deserialized = self._deserialize("StorageAccountCredentialList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,116 +289,132 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials" + } + + @distributed_trace def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccountCredential" + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccountCredential: """Gets the properties of the specified storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountCredential, or the result of cls(response) + :return: StorageAccountCredential or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } def _create_or_update_initial( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccountCredential"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccountCredential"]] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccountCredential]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account_credential, 'StorageAccountCredential') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccountCredential]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account_credential, (IO, bytes)): + _content = storage_account_credential + else: + _json = self._serialize.body(storage_account_credential, "StorageAccountCredential") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -237,127 +423,221 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: _models.StorageAccountCredential, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - storage_account_credential, # type: "_models.StorageAccountCredential" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccountCredential"] + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: """Creates or updates the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account_credential: The storage account credential. - :type storage_account_credential: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential + :param storage_account_credential: The storage account credential. Required. + :type storage_account_credential: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccountCredential or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountCredential"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + storage_account_credential: Union[_models.StorageAccountCredential, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccountCredential]: + """Creates or updates the storage account credential. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The storage account credential name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account_credential: The storage account credential. Is either a model type or a + IO type. Required. + :type storage_account_credential: + ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccountCredential or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountCredential] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccountCredential] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, storage_account_credential=storage_account_credential, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccountCredential', pipeline_response) - + deserialized = self._deserialize("StorageAccountCredential", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -367,74 +647,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the storage account credential. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The storage account credential name. + :param name: The storage account credential name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccountCredentials/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_storage_accounts_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_storage_accounts_operations.py index e559cc8201e0..3169d1b56e46 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_storage_accounts_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,112 +6,280 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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_request( + device_name: str, storage_account_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, storage_account_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, storage_account_name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "storageAccountName": _SERIALIZER.url("storage_account_name", storage_account_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.StorageAccountList"] + self, device_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.StorageAccount"]: """Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. Lists all the StorageAccounts in a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :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 StorageAccountList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccountList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.StorageAccountList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('StorageAccountList', pipeline_response) + deserialized = self._deserialize("StorageAccountList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,118 +288,134 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts" + } + + @distributed_trace def get( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StorageAccount" + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.StorageAccount: """Gets a StorageAccount by name. Gets a StorageAccount by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The storage account name. + :param storage_account_name: The storage account name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } def _create_or_update_initial( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.StorageAccount"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(storage_account, 'StorageAccount') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.StorageAccount]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_account, (IO, bytes)): + _content = storage_account + else: + _json = self._serialize.body(storage_account, "StorageAccount") + + request = build_create_or_update_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -239,129 +424,225 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - storage_account, # type: "_models.StorageAccount" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.StorageAccount"] + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: _models.StorageAccount, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: """Creates a new StorageAccount or updates an existing StorageAccount on the device. Creates a new StorageAccount or updates an existing StorageAccount on the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param storage_account: The StorageAccount properties. + :param storage_account: The StorageAccount properties. Required. :type storage_account: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Required. + :type storage_account: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + device_name: str, + storage_account_name: str, + resource_group_name: str, + storage_account: Union[_models.StorageAccount, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Creates a new StorageAccount or updates an existing StorageAccount on the device. + + Creates a new StorageAccount or updates an existing StorageAccount on the device. + + :param device_name: The device name. Required. + :type device_name: str + :param storage_account_name: The StorageAccount name. Required. + :type storage_account_name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param storage_account: The StorageAccount properties. Is either a model type or a IO type. + Required. + :type storage_account: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.StorageAccount] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.StorageAccount] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, storage_account=storage_account, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) - + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + storage_account_name=storage_account_name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -371,74 +652,76 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } + @distributed_trace def begin_delete( - self, - device_name, # type: str - storage_account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, device_name: str, storage_account_name: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the StorageAccount on the Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param storage_account_name: The StorageAccount name. + :param storage_account_name: The StorageAccount name. Required. :type storage_account_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, storage_account_name=storage_account_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'storageAccountName': self._serialize.url("storage_account_name", storage_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/storageAccounts/{storageAccountName}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_triggers_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_triggers_operations.py index d9813804152e..2bdee0fa6272 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_triggers_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_triggers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,284 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TriggersOperations(object): - """TriggersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class TriggersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`triggers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TriggerList"] + self, device_name: str, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Trigger"]: """Lists all the triggers configured in the device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param filter: Specify $filter='CustomContextTag eq :code:``' to filter on custom context - tag property. + tag property. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TriggerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.TriggerList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Trigger or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TriggerList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.TriggerList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TriggerList', pipeline_response) + deserialized = self._deserialize("TriggerList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +292,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Trigger" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.Trigger: """Get a specific trigger by name. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Trigger, or the result of cls(response) + :return: Trigger or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Trigger"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Trigger"]] + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> Optional[_models.Trigger]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(trigger, 'Trigger') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.Trigger]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(trigger, (IO, bytes)): + _content = trigger + else: + _json = self._serialize.body(trigger, "Trigger") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,127 +419,210 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Trigger', pipeline_response) + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - trigger, # type: "_models.Trigger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Trigger"] + device_name: str, + name: str, + resource_group_name: str, + trigger: _models.Trigger, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: """Creates or updates a trigger. - :param device_name: Creates or updates a trigger. + :param device_name: Creates or updates a trigger. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param trigger: The trigger. + :param trigger: The trigger. Required. :type trigger: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + trigger: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Required. + :type trigger: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Trigger or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trigger"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, trigger: Union[_models.Trigger, IO], **kwargs: Any + ) -> LROPoller[_models.Trigger]: + """Creates or updates a trigger. + + :param device_name: Creates or updates a trigger. Required. + :type device_name: str + :param name: The trigger name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param trigger: The trigger. Is either a model type or a IO type. Required. + :type trigger: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Trigger or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.Trigger] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Trigger] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, trigger=trigger, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Trigger', pipeline_response) - + deserialized = self._deserialize("Trigger", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -371,74 +632,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the trigger on the gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The trigger name. + :param name: The trigger name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/triggers/{name}" + } diff --git a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_users_operations.py b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_users_operations.py index cfcd2c6f7dcf..5413f8b33eb9 100644 --- a/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_users_operations.py +++ b/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2021_02_01_preview/operations/_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,116 +6,284 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_data_box_edge_device_request( + device_name: str, resource_group_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_delete_request( + device_name: str, name: str, 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deviceName": _SERIALIZER.url("device_name", device_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class UsersOperations(object): - """UsersOperations operations. + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # 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) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.databoxedge.v2021_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.databoxedge.v2021_02_01_preview.DataBoxEdgeManagementClient`'s + :attr:`users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + 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 list_by_data_box_edge_device( - self, - device_name, # type: str - resource_group_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.UserList"] + self, device_name: str, resource_group_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.User"]: """Gets all the users registered on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param expand: Specify $expand=details to populate additional fields related to the resource or - Specify $skipToken=:code:`` to populate the next page in the list. + Specify $skipToken=:code:`` to populate the next page in the list. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.UserList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either User or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UserList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.UserList] = kwargs.pop("cls", None) + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_data_box_edge_device.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_data_box_edge_device_request( + device_name=device_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_data_box_edge_device.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('UserList', pipeline_response) + deserialized = self._deserialize("UserList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,116 +292,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_data_box_edge_device.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.User" + list_by_data_box_edge_device.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users" + } + + @distributed_trace + def get(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> _models.User: """Gets the properties of the specified user. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: User, or the result of cls(response) + :return: User or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.User - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + request = build_get_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } def _create_or_update_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.User"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.User"]] + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> Optional[_models.User]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(user, 'User') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.User]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(user, (IO, bytes)): + _content = user + else: + _json = self._serialize.body(user, "User") + + request = build_create_or_update_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -241,128 +419,210 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('User', pipeline_response) + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + @overload def begin_create_or_update( self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - user, # type: "_models.User" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.User"] + device_name: str, + name: str, + resource_group_name: str, + user: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box Gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str - :param user: The user details. + :param user: The user details. Required. :type user: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.User + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + device_name: str, + name: str, + resource_group_name: str, + user: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Required. + :type user: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either User or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, device_name: str, name: str, resource_group_name: str, user: Union[_models.User, IO], **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user's information on a Data Box Edge/Data Box + Gateway device. + + :param device_name: The device name. Required. + :type device_name: str + :param name: The user name. Required. + :type name: str + :param resource_group_name: The resource group name. Required. + :type resource_group_name: str + :param user: The user details. Is either a model type or a IO type. Required. + :type user: ~azure.mgmt.databoxedge.v2021_02_01_preview.models.User or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either User or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.databoxedge.v2021_02_01_preview.models.User] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.User"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, user=user, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('User', pipeline_response) - + deserialized = self._deserialize("User", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_initial( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, device_name: str, name: str, resource_group_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + device_name=device_name, + name=name, + resource_group_name=resource_group_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) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -372,74 +632,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + } - def begin_delete( - self, - device_name, # type: str - name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, device_name: str, name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the user on a databox edge/gateway device. - :param device_name: The device name. + :param device_name: The device name. Required. :type device_name: str - :param name: The user name. + :param name: The user name. Required. :type name: str - :param resource_group_name: The resource group name. + :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2021-02-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-02-01-preview") ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'deviceName': self._serialize.url("device_name", device_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + 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 + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/users/{name}" + }